示例#1
0
 /**
  * Copies a file or directory.
  * @return void
  * @throws Nette\IOException
  */
 public static function copy($source, $dest, $overwrite = TRUE)
 {
     if (stream_is_local($source) && !file_exists($source)) {
         throw new Nette\IOException("File or directory '{$source}' not found.");
     } elseif (!$overwrite && file_exists($dest)) {
         throw new Nette\InvalidStateException("File or directory '{$dest}' already exists.");
     } elseif (is_dir($source)) {
         static::createDir($dest);
         foreach (new \FilesystemIterator($dest) as $item) {
             static::delete($item);
         }
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isDir()) {
                 static::createDir($dest . '/' . $iterator->getSubPathName());
             } else {
                 static::copy($item, $dest . '/' . $iterator->getSubPathName());
             }
         }
     } else {
         static::createDir(dirname($dest));
         if (@stream_copy_to_stream(fopen($source, 'r'), fopen($dest, 'w')) === FALSE) {
             // @ is escalated to exception
             throw new Nette\IOException("Unable to copy file '{$source}' to '{$dest}'.");
         }
     }
 }
示例#2
0
function copyFile($source, $dest)
{
    $is_dot = array('.', '..');
    if (is_dir($source)) {
        if (version_compare((double) phpversion(), (double) '5.3', '<')) {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
        } else {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
        }
        foreach ($iterator as $file) {
            if (version_compare((double) phpversion(), (double) '5.2.17', '<=')) {
                if (in_array($file->getBasename(), $is_dot)) {
                    continue;
                }
            } elseif (version_compare((double) phpversion(), (double) '5.3', '<')) {
                if ($file->isDot()) {
                    continue;
                }
            }
            if ($file->isDir()) {
                mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), true);
            } else {
                copy($file, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
            }
        }
        unset($iterator, $file);
    } else {
        copy($source, $dest);
    }
    return true;
}
示例#3
0
 private static function is_extension_changed($name)
 {
     $name = strtolower($name);
     $extension_build_dir = ROOT_PATH . DS . 'build' . DS . $name;
     $extension_path = ROOT_PATH . DS . 'extensions' . DS . $name . '.tar.gz';
     if (file_exists($extension_build_dir) && file_exists($extension_path)) {
         $dir_iterator = new \RecursiveDirectoryIterator($extension_build_dir);
         /**
          * @var $iterator \RecursiveDirectoryIterator
          */
         $iterator = new \RecursiveIteratorIterator($dir_iterator);
         $iterator->rewind();
         while ($iterator->valid()) {
             if (!$iterator->isDot()) {
                 $file = $extension_build_dir . DS . $iterator->getSubPathName();
                 $phar_file = "phar://{$extension_path}/" . $iterator->getSubPathName();
                 if (!file_exists($phar_file)) {
                     return true;
                 } else {
                     $build_file_hash = md5(file_get_contents($file));
                     $phar_file_hash = md5(file_get_contents($phar_file));
                     if ($build_file_hash != $phar_file_hash) {
                         return true;
                     }
                 }
             }
             $iterator->next();
         }
         return false;
     } else {
         return false;
     }
 }
示例#4
0
 /**
  * Executes a specific Selenium System Tests in your machine
  *
  * @param string $seleniumPath   Optional path to selenium-standalone-server-x.jar
  * @param string $pathToTestFile Optional name of the test to be run
  * @param string $suite          Optional name of the suite containing the tests, Acceptance by default.
  *
  * @return mixed
  */
 public function runTest($pathToTestFile = null, $suite = 'acceptance')
 {
     $this->runSelenium();
     // Make sure to Run the Build Command to Generate AcceptanceTester
     $this->_exec("php vendor/bin/codecept build");
     if (!$pathToTestFile) {
         $this->say('Available tests in the system:');
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('tests/' . $suite, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
         $tests = array();
         $iterator->rewind();
         $i = 1;
         while ($iterator->valid()) {
             if (strripos($iterator->getSubPathName(), 'cept.php') || strripos($iterator->getSubPathName(), 'cest.php')) {
                 $this->say('[' . $i . '] ' . $iterator->getSubPathName());
                 $tests[$i] = $iterator->getSubPathName();
                 $i++;
             }
             $iterator->next();
         }
         $this->say('');
         $testNumber = $this->ask('Type the number of the test  in the list that you want to run...');
         $test = $tests[$testNumber];
     }
     $pathToTestFile = 'tests/' . $suite . '/' . $test;
     $this->taskCodecept()->test($pathToTestFile)->arg('--steps')->arg('--debug')->run()->stopOnFail();
     // Kill selenium server
     // $this->_exec('curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer');
 }
示例#5
0
 public function copy($target)
 {
     $result = false;
     $encoded = $this->encodePath($target);
     $dir = dirname($encoded);
     if (!is_dir($encoded)) {
         $result = mkdir($encoded, 0755, true);
     }
     if (is_dir($encoded)) {
         $result = true;
         // needed for empty directories
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->_encoded), \RecursiveIteratorIterator::SELF_FIRST);
         foreach ($iterator as $f) {
             if ($f->isDir()) {
                 $path = $encoded . '/' . $iterator->getSubPathName();
                 if (!is_dir($path)) {
                     $result = mkdir($path);
                 }
             } else {
                 $result = copy($f, $encoded . '/' . $iterator->getSubPathName());
             }
             if ($result === false) {
                 break;
             }
         }
     }
     if ($result) {
         $this->setPath($target);
     }
     return $result;
 }
示例#6
0
function copyOldVersion()
{
    if (!is_dir(PATH)) {
        echo 'Creating new oldVersion dir...<br>';
        mkdir(PATH);
    }
    $source = "../";
    $dest = PATH;
    // Set a stream context timeout for file reading
    $context = stream_context_create(array('http' => array('timeout' => 60)));
    echo 'Moving current ICEcoder files...<br>';
    foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
        if (strpos($source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), "oldVersion") == false) {
            // Don't move backups, plugins or .git away
            $testPath = $source . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            $testPath = str_replace("\\", "/", $testPath);
            if (strpos($testPath, "/backups/") == false && strpos($testPath, "/plugins/") == false && strpos($testPath, "/.git/") == false) {
                if ($item->isDir()) {
                    mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0755);
                } else {
                    rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
                }
            }
        }
    }
    $icv_url = "https://icecoder.net/latest-version.txt";
    echo 'Detecting current version of ICEcoder...<br>';
    $icvInfo = getData($icv_url, 'curl', 'Sorry, couldn\'t figure out latest version.');
    echo 'Latest version of ICEcoder is ' . $icvInfo . '<br>';
    openZipNew($icvInfo);
}
 /**
  * {@inheritdoc}
  *
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $assets = $this->getContainer()->getParameter('asf_layout.assets');
     $this->tinymce_config = $assets['tinymce'];
     $dest_dir = $input->getArgument('target_dir') ? $input->getArgument('target_dir') : null;
     if (is_null($dest_dir) && isset($this->tinymce_config['customize']['dest_dir'])) {
         $dest_dir = $this->tinymce_config['customize']['dest_dir'];
     }
     $exclude_files = $input->getOption('exclude_files') ? $input->getOption('exclude_files') : $this->tinymce_config['customize']['exclude_files'];
     $src_dir = sprintf('%s', $this->tinymce_config['tinymce_dir']);
     $fs = new Filesystem();
     try {
         if (!$fs->exists($dest_dir)) {
             $fs->mkdir($dest_dir);
         }
     } catch (IOException $e) {
         $output->writeln(sprintf('<error>Could not create directory %s.</error>', $dest_dir));
         return;
     }
     if (false === file_exists($src_dir)) {
         $output->writeln(sprintf('<error>Source directory "%s" does not exist. Did you install TinyMCE ? ' . 'Don\'t forget to specify the path to TinyMCE folder in ' . '"asf_layout.assets.tinymce.tinymce_dir".</error>', $src_dir));
         return;
     }
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src_dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir() && !in_array($item->getBasename(), $exclude_files)) {
             $fs->mkdir($dest_dir . '/' . $iterator->getSubPathName());
         } elseif (!in_array($item->getBasename(), $exclude_files)) {
             $fs->copy($item, $dest_dir . '/' . $iterator->getSubPathName());
         }
     }
     $output->writeln(sprintf('[OK] TinyMCE files was successfully copied in "%s".', $dest_dir));
 }
示例#8
0
 function copy_r($source, $dest)
 {
     @mkdir($dest, 0755, TRUE);
     foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             @mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         } else {
             @copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
示例#9
0
文件: 2014-03.php 项目: gotcms/gotcms
function moveDirectory($source, $dest)
{
    foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
        if ($item->isDir()) {
            mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
        } else {
            rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
        }
        echo 'Move: ' . $iterator->getSubPathName() . PHP_EOL;
    }
}
 /**
  * Recursive Copy
  *
  * @param string $src
  * @param string $dst
  */
 private static function recursiveCopy($src, $dst)
 {
     mkdir($dst, 0755);
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isDir()) {
             mkdir($dst . '/' . $iterator->getSubPathName());
         } else {
             copy($file, $dst . '/' . $iterator->getSubPathName());
         }
     }
 }
示例#11
0
 public function copy($src, $dst)
 {
     $this->createDirectory($dst);
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         if (!$item->isLink() && $item->isDir()) {
             mkdir($dst . '/' . $iterator->getSubPathName());
             continue;
         }
         copy($item, $dst . '/' . $iterator->getSubPathName());
     }
 }
示例#12
0
 public static function DirectoryContent($Directory, $UserLanguage)
 {
     $ReadDirectory = $Directory . str_replace('.language', '', $UserLanguage);
     $Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($ReadDirectory));
     $FilesArray = array();
     while ($Iterator->valid()) {
         if (!$Iterator->isDot()) {
             $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName(), 'SmallFileName' => strtolower(str_replace('.language', '', $Iterator->getSubPathName())), 'LinesCount' => File::CountLines($Iterator->key()));
         }
         $Iterator->next();
     }
     return $FilesArray;
 }
示例#13
0
 /**
  * Because phing needs to use files from stub directory, we need to copy them to the
  * directory, to make them readable by phing.
  * When phing finishes work, this directory will be removed.
  */
 public function copyStub()
 {
     $source = 'phar://vegaser.phar' . DIRECTORY_SEPARATOR . 'stub';
     $dest = '.' . DIRECTORY_SEPARATOR . 'stub';
     shell_exec('mkdir ' . $dest);
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         } else {
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
/**
 * Copies a directory recursively.
 *
 * @param string $source The source path to copy.
 * @param string $target The target path to copy to.
 */
function copyDirectory($source, $target)
{
    /** @var $iterator \RecursiveIteratorIterator|\RecursiveDirectoryIterator */
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
    foreach ($iterator as $file) {
        /** @var $file SplFileInfo */
        if ($file->isDir()) {
            mkdir($target . '/' . $iterator->getSubPathName());
            continue;
        }
        copy($file, $target . '/' . $iterator->getSubPathName());
    }
}
示例#15
0
 public static function copyFolder($source, $dest)
 {
     if (!is_dir($dest)) {
         @mkdir($dest);
     }
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             @mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         } else {
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
 public static function copy_dir($source, $dest)
 {
     mkdir($dest, 0755);
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             /**
              * @var $iterator \RecursiveDirectoryIterator
              */
             mkdir($dest . DS . $iterator->getSubPathName());
         } else {
             copy($item, $dest . DS . $iterator->getSubPathName());
         }
     }
 }
 private function xcopy($source, $dest)
 {
     $base = base_path();
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             if (!is_dir($dest . '/' . $iterator->getSubPathName())) {
                 mkdir($dest . '/' . $iterator->getSubPathName());
             }
         } else {
             copy($item, $dest . '/' . $iterator->getSubPathName());
             $this->line('   Copying -> ' . str_replace($base, '', $dest . '/' . $iterator->getSubPathName()));
         }
     }
 }
示例#18
0
 /**
  * Recursively clone the uploads directory, including all files and sub-directories.
  * @return void
  */
 protected function cloneUploadsDirectory($from, $to)
 {
     if (file_exists($from) === false) {
         return false;
     } else {
         mkdir($to, 0755);
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($from, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isDir()) {
                 mkdir($to . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
             } else {
                 copy($item, $to . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
             }
         }
     }
 }
 public static function init()
 {
     // Copy the view folder to vendor
     $source = "view";
     $dest = "vendor/louislam/louislam-crud/view";
     Bootstrap::removeDir($dest);
     mkdir($dest, 0777, true);
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0777, true);
         } else {
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
示例#20
0
 public function copyTemplate($siteType, $templateId, $destionPath)
 {
     $site = $this->getWebsiteInfoFrom($siteType);
     $template = $site['template']::findOrFail($templateId);
     if (!file_exists($destionPath)) {
         mkdir($destionPath, 0755, true);
     }
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(public_path() . $template->path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             mkdir($destionPath . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         } else {
             copy($item, $destionPath . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
 private function copyTemplates()
 {
     // check if there's a /templates in plugin directory
     $source_path = ROOT_PATH . 'plugins/' . $this->getName() . '/templates';
     if (!file_exists($source_path)) {
         return;
     }
     // create directory in /templates/plugins/ if not exists
     $plugin_template_path = ROOT_PATH . 'templates/plugins/' . $this->getName();
     if (!file_exists($plugin_template_path)) {
         mkdir($plugin_template_path);
     }
     // copy static files to that directory
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         $path = $plugin_template_path . '/' . $iterator->getSubPathName();
         if ($item->isDir()) {
             if (!file_exists($path)) {
                 mkdir($path);
             }
         } else {
             copy($item, $path);
         }
     }
 }
 /**
  * Recursively copy assets from the source directory to the destination
  * directory in the web space, omitting source files.
  *
  * @param  Filesystem        $fs
  * @param  string            $from_directory the source
  * @param  string            $to_directory   the destination
  * @throws \RuntimeException if a problem occurs.
  */
 protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
 {
     Tlog::getInstance()->addDebug("Copying assets from {$from_directory} to {$to_directory}");
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     $fs->mkdir($to_directory, 0777);
     /** @var \RecursiveDirectoryIterator $iterator */
     foreach ($iterator as $item) {
         if ($item->isDir()) {
             $dest_dir = $to_directory . DS . $iterator->getSubPathName();
             if (!is_dir($dest_dir)) {
                 if ($fs->exists($dest_dir)) {
                     $fs->remove($dest_dir);
                 }
                 $fs->mkdir($dest_dir, 0777);
             }
         } elseif (!$this->isSourceFile($item)) {
             // We don't copy source files
             $dest_file = $to_directory . DS . $iterator->getSubPathName();
             if ($fs->exists($dest_file)) {
                 $fs->remove($dest_file);
             }
             $fs->copy($item, $dest_file);
         }
     }
 }
示例#23
0
 public function testBuildPhar()
 {
     if (defined('HHVM_VERSION')) {
         $this->markTestSkipped('Building the phar does not work on HHVM.');
     }
     $target = dirname(self::$pharPath);
     $fs = new Filesystem();
     $fs->removeDirectory($target);
     $fs->ensureDirectoryExists($target);
     chdir($target);
     $it = new \RecursiveDirectoryIterator(__DIR__ . '/../../../', \RecursiveDirectoryIterator::SKIP_DOTS);
     $ri = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($ri as $file) {
         $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
         if ($file->isDir()) {
             $fs->ensureDirectoryExists($targetPath);
         } else {
             copy($file->getPathname(), $targetPath);
         }
     }
     $proc = new Process('php ' . escapeshellarg('./bin/compile'), $target);
     $exitcode = $proc->run();
     if ($exitcode !== 0 || trim($proc->getOutput())) {
         $this->fail($proc->getOutput());
     }
     $this->assertTrue(file_exists(self::$pharPath));
 }
 protected function assertDirContentsEquals($expDir, $actDir)
 {
     if (!file_exists($expDir)) {
         throw new RuntimeException("Expected dir not found: " . $expDir);
     }
     if (!file_exists($actDir)) {
         throw new RuntimeException("Actual dir not found: " . $actDir);
     }
     $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($expDir));
     $expFiles = array();
     while ($dir->valid()) {
         if (!$dir->isDot()) {
             array_push($expFiles, $dir->getSubPathName());
         }
         $dir->next();
     }
     $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($actDir));
     $actFiles = array();
     while ($dir->valid()) {
         if (!$dir->isDot()) {
             array_push($actFiles, $dir->getSubPathName());
         }
         $dir->next();
     }
     $this->assertEquals($expFiles, $actFiles);
     foreach ($expFiles as $key => $value) {
         $expFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $value);
         $actFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $actFiles[$key]);
         $this->assertEquals($expFile, $actFile);
     }
 }
示例#25
0
 private static function recursiveCopy($source, $dest)
 {
     if (!is_dir($dest)) {
         mkdir($dest, 0755, true);
     }
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         if ($item->isDir()) {
             $target = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
             if (!is_dir($target)) {
                 mkdir($target);
             }
         } else {
             echo "Copying:\nSource:" . $item . "\nDestination:" . $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName() . "\n\n";
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
示例#26
0
function Q_configure_copy($source, $dest)
{
    if (file_exists($dest)) {
        if (!is_dir($dest)) {
            throw new Exception(APP_DIR . '/local must be a directory. What happened?');
        }
    } else {
        mkdir($dest);
    }
    foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
        if ($item->isDir()) {
            mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
        } else {
            copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
        }
    }
}
示例#27
0
function copyOldVersion()
{
    if (!is_dir(PATH)) {
        echo 'Creating new oldVersion dir...<br>';
        mkdir(PATH);
    }
    $source = "../";
    $dest = PATH;
    // Set a stream context timeout for file reading
    $context = stream_context_create(array('http' => array('timeout' => 60)));
    echo 'Moving current ICEcoder files...<br>';
    foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
        if (strpos($source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), "oldVersion") == false) {
            // Don't move plugins away
            $testPath = $source . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            $testPath = str_replace("\\", "/", $testPath);
            if (strpos($testPath, "/plugins/") == false) {
                if ($item->isDir()) {
                    mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0705);
                } else {
                    rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
                }
            }
        }
    }
    $icv_url = "https://icecoder.net/latest-version.txt";
    echo 'Detecting current version of ICEcoder...<br>';
    if (ini_get('allow_url_fopen')) {
        $icvInfo = @file_get_contents($icv_url, false, $context);
        if (!$icvInfo) {
            $icvInfo = file_get_contents(str_replace("https:", "http:", $icv_url), false, $context);
        }
    } elseif (function_exists('curl_init')) {
        $ch = curl_init($icv_url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $icvInfo = curl_exec($ch);
    } else {
        die('Sorry, couldn\'t figure out latest version.');
    }
    echo 'Latest version of ICEcoder is ' . $icvInfo . '<br>';
    openZipNew($icvInfo);
}
示例#28
0
 /**
  * @param $source
  * @param $target
  * @param OutputInterface $output
  */
 protected function copyConfigFiles($source, $target, OutputInterface $output)
 {
     try {
         $progress = new ProgressBar($output, 3720);
         $progress->start();
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isDir()) {
                 mkdir($target . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
             } else {
                 copy($item, $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
             }
             $progress->advance();
         }
         $progress->finish();
         echo "\n";
     } catch (\Exception $e) {
         $output->writeln('<error>There was an error while setting up the project structure</error>');
     }
 }
 public static function mirror($source, $dest)
 {
     @mkdir($dest, 0755, true);
     // We only want to do this if the two directories don't match
     if (realpath($source) === realpath($dest)) {
         return;
     }
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         if ($item->isDir()) {
             $new = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
             if (!is_dir($new)) {
                 mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
             }
         } else {
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
 }
示例#30
0
 public static function GetDirectoryContent($Directory, $SearchForFormat = null)
 {
     $Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Directory));
     $FilesArray = array();
     while ($Iterator->valid()) {
         if (!$Iterator->isDot()) {
             if ($SearchForFormat != null) {
                 $Exploded = explode('.', $Iterator->getSubPathName());
                 if ($Exploded[1] == $SearchForFormat) {
                     $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
                 }
             } else {
                 $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
             }
         }
         $Iterator->next();
     }
     return $FilesArray;
 }