AbstractDownloader.php 873 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Downloader;
  12. use Composer\Package\PackageInterface;
  13. /**
  14. * @author Jordi Boggiano <j.boggiano@seld.be>
  15. * @author Benjamin Eberlei <kontakt@beberlei.de>
  16. */
  17. abstract class AbstractDownloader
  18. {
  19. protected function downloadFile($url, $path)
  20. {
  21. $file = fopen($url, "rb");
  22. if ($file) {
  23. $newf = fopen($path, "wb");
  24. if ($newf) {
  25. while (!feof($file)) {
  26. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  27. }
  28. fclose($newf);
  29. }
  30. fclose($file);
  31. }
  32. }
  33. }