当前位置: 首页>>代码示例>>PHP>>正文


PHP Folder::move方法代码示例

本文整理汇总了PHP中Cake\Filesystem\Folder::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::move方法的具体用法?PHP Folder::move怎么用?PHP Folder::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Filesystem\Folder的用法示例。


在下文中一共展示了Folder::move方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 /**
  * Extract valid theme archive.
  *
  * @return $this|void
  */
 public function extract()
 {
     $Zip = $this->zip();
     $Theme = ThemeExtension::getInstance();
     $name = $this->_attr->get('name');
     $path = $Theme->getPath() . $name . DS;
     $alias = Plugin::nameToAlias($name);
     $isExits = $this->table()->findByAlias($alias)->first();
     if (is_dir($path) && $isExits !== null) {
         $this->_setOutput(__d('extensions', 'The theme «{0}» already exits.', sprintf('<strong>%s</strong>', $name)));
     }
     new Folder($path);
     $tmp = $this->_request->data($this->_inputName);
     $Zip->open($tmp);
     $Zip->extractTo($path);
     if (!empty($this->_rootPath[$tmp])) {
         $old = $path . DS . $this->_rootPath[$tmp];
         $new = $path;
         $Folder = new Folder($old);
         $Folder->move($new);
     }
     $this->_setResult(true);
     $this->_setOutput(__d('extensions', 'The theme «{0}» has bin successful uploaded.', sprintf('<strong>%s</strong>', $name)), true);
     return $this;
 }
开发者ID:Cheren,项目名称:union,代码行数:30,代码来源:Theme.php

示例2: install

 /**
  * Installing plugin
  * @param null $zipPath
  * @return array|bool
  * @throws CakeException
  */
 public function install($zipPath = null)
 {
     if (!file_exists($zipPath)) {
         throw new Exception(__d('spider', 'Invalid plugin file path'));
     }
     $pluginInfo = $this->getPluginMeta($zipPath);
     $pluginHomeDir = App::path('Plugin');
     $pluginHomeDir = reset($pluginHomeDir);
     $pluginPath = $pluginHomeDir . $pluginInfo->name . DS;
     if (is_dir($pluginPath)) {
         throw new Exception(__d('spider', 'Plugin already exists'));
     }
     $Zip = new \ZipArchive();
     if ($Zip->open($zipPath) === true) {
         new Folder($pluginPath, true);
         $Zip->extractTo($pluginPath);
         if (!empty($pluginInfo->rootPath)) {
             $old = $pluginPath . $pluginInfo->rootPath;
             $new = $pluginPath;
             $Folder = new Folder($old);
             $Folder->move($new);
         }
         $Zip->close();
         return (array) $pluginInfo;
     } else {
         throw new CakeException(__d('spider', 'Failed to extract plugin'));
     }
     return false;
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:35,代码来源:PluginInstaller.php

示例3: _unzip

 /**
  * Extracts the current ZIP package.
  *
  * @param  string $file Full path to the ZIP package
  * @return bool True on success
  */
 protected function _unzip($file)
 {
     include_once Plugin::classPath('Installer') . 'Lib/pclzip.lib.php';
     $File = new File($file);
     $to = normalizePath($File->folder()->pwd() . '/' . $File->name() . '_unzip/');
     if (is_readable($to)) {
         $folder = new Folder($to);
         $folder->delete();
     } else {
         $folder = new Folder($to, true);
     }
     $PclZip = new \PclZip($file);
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/__MACOSX/');
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/\\.DS_Store$/');
     if ($PclZip->extract(PCLZIP_OPT_PATH, $to)) {
         list($directories, $files) = $folder->read(false, false, true);
         if (count($directories) === 1 && empty($files)) {
             $container = new Folder($directories[0]);
             $container->move(['to' => $to]);
         }
         $this->_workingDir = $to;
         return true;
     }
     $this->err(__d('installer', 'Unzip error: {0}', [$PclZip->errorInfo(true)]));
     return false;
 }
开发者ID:quickapps-plugins,项目名称:installer,代码行数:32,代码来源:PluginInstallTask.php

示例4: testMoveWithoutRecursive

 public function testMoveWithoutRecursive()
 {
     extract($this->_setupFilesystem());
     $Folder = new Folder($folderOne);
     $result = $Folder->move(['to' => $folderTwo, 'recursive' => false]);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertFalse(is_dir($folderTwo . '/folderA'));
     $this->assertFalse(file_exists($folderTwo . '/folderA/fileA.php'));
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:10,代码来源:FolderTest.php

示例5: testMoveWithSkip

 /**
  * testMoveWithSkip method
  *
  * Verify that directories and files are moved recursively
  * even if the destination directory already exists.
  * Subdirectories existing in both destination and source directory
  * are skipped and not merged or overwritten.
  *
  * @return void
  */
 public function testMoveWithSkip()
 {
     extract($this->_setupFilesystem());
     $Folder = new Folder($folderOne);
     $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertTrue(is_dir($folderTwo . '/folderB'));
     $this->assertTrue(file_exists($folderTwoB . '/fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     touch($fileOne);
     touch($fileOneA);
     $Folder = new Folder($folderOne);
     $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertTrue(is_dir($folderTwo . '/folderA'));
     $this->assertTrue(file_exists($folderTwo . '/folderA/fileA.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     new Folder($folderTwoB, true);
     touch($fileOne);
     touch($fileOneA);
     file_put_contents($folderTwoB . '/fileB.php', 'untouched');
     $Folder = new Folder($folderOne);
     $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertEquals('untouched', file_get_contents($folderTwoB . '/fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($path);
     $Folder->delete();
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:58,代码来源:FolderTest.php

示例6: commit

 /**
  * Write staged changes
  *
  * If it's a dry run though - only show what will be done, don't do anything
  *
  * @param string $path file path
  * @return void
  */
 public function commit($path = null)
 {
     if (!$path) {
         foreach (array_keys($this->_staged['change']) as $path) {
             $this->commit($path);
         }
         foreach ($this->_staged['move'] as $path => $to) {
             if (isset($this->_staged['change'][$path])) {
                 continue;
             }
             $this->commit($path);
         }
         foreach ($this->_staged['delete'] as $path) {
             $this->commit($path);
         }
         $Folder = new Folder(TMP . 'upgrade');
         $Folder->delete();
         return;
     }
     $dryRun = !empty($this->params['dry-run']);
     $isMove = isset($this->_staged['move'][$path]);
     $isChanged = isset($this->_staged['change'][$path]) && count($this->_staged['change'][$path]) > 1;
     $isDelete = in_array($path, $this->_staged['delete']);
     if (!$isMove && !$isChanged && !$isDelete) {
         return;
     }
     $gitCd = sprintf('cd %s && ', escapeshellarg(dirname($path)));
     if ($isDelete) {
         $this->out(sprintf('<info>Delete %s</info>', Debugger::trimPath($path)));
         if ($dryRun) {
             return true;
         }
         if (!empty($this->params['git'])) {
             exec($gitCd . sprintf('git rm -f %s', escapeshellarg($path)));
             return;
         }
         if (is_dir($path)) {
             $Folder = new Folder($path);
             return $Folder->delete();
         }
         $File = new File($path, true);
         return $File->delete();
     }
     if ($isMove && !$isChanged) {
         $to = $this->_staged['move'][$path];
         $this->out(sprintf('<info>Move %s to %s</info>', Debugger::trimPath($path), Debugger::trimPath($to)));
         if ($dryRun || !file_exists($path)) {
             return true;
         }
         if (!empty($this->params['git'])) {
             return $this->_gitMove($gitCd, $path, $to);
         }
         if (is_dir($path)) {
             $Folder = new Folder($path);
             return $Folder->move($to);
         }
         $File = new File($to, true);
         return $File->write(file_get_contents($path)) && unlink($path);
     }
     $start = reset($this->_staged['change'][$path]);
     end($this->_staged['change'][$path]);
     $final = end($this->_staged['change'][$path]);
     $oPath = TMP . 'upgrade' . DS . $start;
     $uPath = TMP . 'upgrade' . DS . $final;
     exec('git diff --no-index ' . escapeshellarg($oPath) . ' ' . escapeshellarg($uPath), $output);
     $output = implode($output, "\n");
     $i = strrpos($output, $final);
     $diff = substr($output, $i + 41);
     if ($isMove) {
         $to = $this->_staged['move'][$path];
         $this->out(sprintf('<info>Move %s to %s and update</info>', Debugger::trimPath($path), Debugger::trimPath($to)));
     } else {
         $this->out(sprintf('<info>Update %s</info>', Debugger::trimPath($path)));
     }
     $this->out($diff, 1, $dryRun ? Shell::NORMAL : SHELL::VERBOSE);
     if ($dryRun || !file_exists($path)) {
         return true;
     }
     if ($isMove) {
         if (!empty($this->params['git'])) {
             $this->_gitMove($gitCd, $path, $to);
         } else {
             unlink($path);
         }
         $path = $to;
     }
     $File = new File($path, true);
     return $File->write(file_get_contents($uPath));
 }
开发者ID:cakephp,项目名称:upgrade,代码行数:97,代码来源:StageTask.php


注:本文中的Cake\Filesystem\Folder::move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。