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


PHP File::copy方法代码示例

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


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

示例1: copyFile

 protected function copyFile($file, $target)
 {
     if (!\File::exists($target)) {
         return \File::copy($file, $target);
     }
     return false;
 }
开发者ID:drecon,项目名称:molar,代码行数:7,代码来源:ControllerCommand.php

示例2: copyDir

 /**
  * Recursively copy a folder and its contents
  * http://aidan.dotgeek.org/lib/?file=function.copyr.php
  *
  * @author      Aidan Lister <aidan@php.net>
  * @version     1.0.1
  * @param       string   $source    Source path
  * @param       string   $dest      Destination path
  * @return      bool     Returns TRUE on success, FALSE on failure
  */
 function copyDir($source, $dest)
 {
     clearstatcache();
     // Simple copy for a file
     if (is_file($source)) {
         return File::copy($source, $dest);
     }
     // Make destination directory
     if (!File::isDir($dest)) {
         File::createDir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         if ($dest !== "{$source}/{$entry}") {
             MyFile::copyDir("{$source}/{$entry}", "{$dest}/{$entry}");
         }
     }
     // Clean up
     $dir->close();
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:37,代码来源:myfile.class.php

示例3: copy

 /**
  * Copies the directory within all files to the destination.
  * @param string $destination The destination path.
  * @param boolean $overwrite If already exists overwrite it or not.
  * @param boolean $mt Keep the modification time of the directory or not.
  * @throws FileException If failed to copy the directory.
  * @return Directory The copied directory.
  */
 public function copy($destination, $overwrite = false, $mt = false)
 {
     if (dirname($destination) == ".") {
         $destination = $this->getDirectory() . DS . $destination;
     }
     $destination = $this->preparePath($destination, false);
     if (strcmp(substr($destination, -1), DS) == 0) {
         $destination .= $this->getName();
     }
     foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->pathAbsolute, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
         $path = $iterator->getSubPathName();
         $dest = $destination . DS . $path;
         $d = Config::$root . $dest;
         if ($item->isDir()) {
             if (!file_exists($d) && !mkdir($d, $this->permission, true)) {
                 throw new FileException(array("Directory '%s' not exists.", $dest));
             }
             if ($mt) {
                 $filemtime = $item->getMTime();
                 @touch($d, $filemtime);
             }
         } else {
             $file = new File($this->path . DS . $path);
             $file->copy($dest, $overwrite, $mt);
         }
     }
     return new Directory($destination);
 }
开发者ID:rolandrajko,项目名称:BREAD,代码行数:36,代码来源:Directory.php

示例4: copy

 /**
  * Copy directory to another directory location
  *
  * @param \Drone\Filesystem\Directory $directory (directory object with copy location)
  * @return boolean
  */
 public function copy(\Drone\Filesystem\Directory $directory, $chmod = 0644)
 {
     if (!$this->__isDir()) {
         return false;
     }
     if (!$directory->create($chmod)) {
         $this->error = 'Failed to create new directory \'' . $directory->getPath() . '\'';
         return false;
     }
     foreach ($this->read(false, true) as $asset) {
         if ($asset['type'] === 'dir') {
             $dir = new Directory($this->_path . $asset['name'], false);
             if (!$dir->copy(new Directory($directory->getPath() . $asset['name'], false), $chmod)) {
                 $this->error = 'Failed to create new subdirectory \'' . $dir->getPath() . '\' (' . $dir->error . '), try elevated chmod';
                 return false;
             }
         } else {
             $file = new File($this->_path . $asset['name'], false);
             if (!$file->copy(new File($directory->getPath() . $asset['name'], false), $chmod)) {
                 $this->error = 'Failed to create new file \'' . $file->getPath() . '\' (' . $file->error . '), try elevated chmod';
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:NHoeller,项目名称:drone,代码行数:32,代码来源:Directory.php

示例5: execute

 function execute()
 {
     $file_or_folder = $this->file_or_folder;
     if (self::$dummy_mode) {
         echo "Adding : " . $file_or_folder . "<br />";
         return;
     }
     $root_dir_path = self::$root_dir->getPath();
     $file_or_folder = str_replace("\\", "/", $file_or_folder);
     $file_list = array();
     //se finisce con lo slash è una directory
     if (substr($file_or_folder, strlen($file_or_folder) - 1, 1) == "/") {
         //creo la cartella
         $target_dir = new Dir(DS . $root_dir_path . $file_or_folder);
         $target_dir->touch();
         $source_dir = new Dir($this->module_dir->getPath() . $file_or_folder);
         foreach ($source_dir->listFiles() as $elem) {
             if ($elem->isDir()) {
                 $file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getName() . DS));
             } else {
                 $file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getFilename()));
             }
         }
     } else {
         $source_file = new File($this->module_dir->getPath() . $file_or_folder);
         $target_file = new File($root_dir_path . $file_or_folder);
         $target_dir = $target_file->getDirectory();
         $target_dir->touch();
         $source_file->copy($target_dir);
         $file_list[] = $target_dir->newFile($source_file->getFilename())->getPath();
     }
     return $file_list;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:33,代码来源:AddModuleAction.class.php

示例6: copy

 /**
  * copies files/directories recursively
  * @param  string  $source    from
  * @param  string  $dest      to
  * @param  boolean $overwrite overwrite existing file
  * @return void             
  */
 public static function copy($source, $dest, $overwrite = false)
 {
     //Lets just make sure our new folder is already created. Alright so its not efficient to check each time... bite me
     if (is_file($dest)) {
         copy($source, $dest);
         return;
     }
     if (!is_dir($dest)) {
         mkdir($dest);
     }
     $objects = scandir($source);
     foreach ($objects as $object) {
         if ($object != '.' && $object != '..') {
             $path = $source . '/' . $object;
             if (is_file($path)) {
                 if (!is_file($dest . '/' . $object) || $overwrite) {
                     if (!@copy($path, $dest . '/' . $object)) {
                         die('File (' . $path . ') could not be copied, likely a permissions problem.');
                     }
                 }
             } elseif (is_dir($path)) {
                 if (!is_dir($dest . '/' . $object)) {
                     mkdir($dest . '/' . $object);
                 }
                 // make subdirectory before subdirectory is copied
                 File::copy($path, $dest . '/' . $object, $overwrite);
                 //recurse!
             }
         }
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:38,代码来源:file.php

示例7: copy

 /**
  * Create a copy of the file
  *
  * @param   string  $from  The full path of the file to copy from
  * @param   string  $to    The full path of the file that will hold the copy
  *
  * @return  boolean  True on success
  */
 public function copy($from, $to)
 {
     $ret = $this->fileAdapter->copy($from, $to);
     if (!$ret && is_object($this->abstractionAdapter)) {
         return $this->abstractionAdapter->copy($from, $to);
     }
     return $ret;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:16,代码来源:Hybrid.php

示例8: replace

 function replace($path)
 {
     $F = new File($path);
     $md5 = $F->md5();
     $this->path = appPATH . 'qg/file/' . $md5;
     $F->copy($this->path);
     $this->setVs(array('name' => $F->basename(), 'mime' => $F->mime(), 'text' => $F->getText(), 'md5' => $F->md5(), 'size' => $F->size()));
 }
开发者ID:nikbucher,项目名称:shwups-cms-v4,代码行数:8,代码来源:dbFile.class.php

示例9: seed

 /**
  * Seeds with a randomly generated Project
  *
  * @param $iteration String: the current iteration
  * @return mixed
  */
 public function seed($iteration)
 {
     factory(Project::class, 1)->create(['author' => $this->faker->userName, 'title' => preg_replace('/[^a-z0-9 ]+/i', "", $this->faker->realText(32)), 'description' => $this->faker->realText(30), 'body' => $this->faker->realText()]);
     $newestID = DB::table('projects')->orderBy('created_at', 'desc')->first()->id;
     //Get the project that was just created's id
     $imagePath = 'public/images/projects/' . 'product' . $newestID . '.jpg';
     File::copy($this->images[$iteration % 6], $imagePath);
 }
开发者ID:uidaho,项目名称:squireproject,代码行数:14,代码来源:ProjectsTableMassSeeder.php

示例10: copyFiles

 protected function copyFiles()
 {
     $files = \File::files(base_path());
     foreach ($files as $file) {
         $path = str_replace(base_path(), '', $file);
         \File::copy($file, base_path() . '/backup/' . $this->timestamp . '/' . $path);
     }
 }
开发者ID:voltcms,项目名称:backup,代码行数:8,代码来源:Backup.php

示例11: _createConfigFile

 /**
  * Create the config file copying the config.php.install file
  */
 private function _createConfigFile()
 {
     $destinationPath = App::pluginPath('Gallery') . 'config' . DS . 'config.php';
     if (!file_exists($destinationPath)) {
         $configFile = new File(App::pluginPath('Gallery') . 'config' . DS . 'config.php.install');
         $configFile->copy($destinationPath);
     }
 }
开发者ID:brnagn7,项目名称:spydercake,代码行数:11,代码来源:InstallController.php

示例12: testRemoveFile

 public function testRemoveFile()
 {
     $fileName = $this->destinationPath . 'avatar.png';
     $thumbName = $this->destinationPath . 'thumb_avatar.png';
     $file = new File($this->originPath . 'avatar.png');
     $file->copy($fileName);
     $this->assertTrue($this->behavior->removeFile($this->model, $fileName));
 }
开发者ID:jeffersongoncalves,项目名称:cake-base,代码行数:8,代码来源:UploadBehaviorTest.php

示例13: main

 public function main()
 {
     $Folder = new Folder(dirname(dirname(dirname(__FILE__))) . DS . "features");
     $this->out("copy " . $Folder->pwd() . " to Cake Root...");
     $Folder->copy(array('to' => ROOT . DS . "features"));
     $File = new File(dirname(__FILE__) . DS . "behat.yml.default");
     $this->out("copy " . $File->name() . " to App/Config...");
     $File->copy(APP . DS . "Config" . DS . "behat.yml");
 }
开发者ID:nojimage,项目名称:Bdd,代码行数:9,代码来源:InitShell.php

示例14: genFlapUpdateFile

 /**
  * 產生輔翼系統更新會員資料檔案
  * 
  * @return string $dest
  */
 public function genFlapUpdateFile()
 {
     $file = __DIR__ . '/../../../../../storage/excel/example/updateFormat.xls';
     $dest = $this->getUpdateFilePath();
     if (!\File::copy($file, $dest)) {
         throw new \Exception('Could not copy file!');
     }
     return $this;
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:14,代码来源:FileHelper.php

示例15: getPicture

 public function getPicture($params = [])
 {
     $pic = __DIR__ . '/../../tests/files/temp.jpg';
     $params = array_merge(['name' => 'picture.jpg'], $params);
     if (!is_file($pic)) {
         File::copy(__DIR__ . '/../../tests/files/chrysanthemum.jpg', $pic);
     }
     return new UploadedFile($pic, $params['name'], 'image/jpeg', null, null, true);
 }
开发者ID:escapework,项目名称:laramedias,代码行数:9,代码来源:TestCase.php


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