Creates a copy of $srcFilePath from DFS to $dstFilePath on DFS

@param string $srcFilePath Local source file path
@param string $dstFilePath Local destination file path

@return bool
778805
public function copyFromDFSToDFS( $srcFilePath, $dstFilePath )
    {
        $srcHandler = $this->getHandler( $srcFilePath );
        $dstHandler = $this->getHandler( $dstFilePath );

        if ( $srcHandler === $dstHandler )
        {
            return $srcHandler->copyFromDFSToDFS( $srcFilePath, $dstFilePath );
        }
        else
        {
            return $dstHandler->createFileOnDFS( $dstFilePath, $srcHandler->getContents( $srcFilePath ) );
        }
    }
487446
public function copyFile($origFilePath, $targetFilePath, $publicAccess = true)
	{
		$origFilePath = str_replace('//', '/', $origFilePath);
		$targetFilePath = str_replace('//', '/', $targetFilePath);
		$result = $this->s3Client->copyObject(array(
			'Bucket' => $this->getBucket(),
			'CopySource' => $origFilePath,
			'Key'    => $targetFilePath,
			'ACL'    => $publicAccess ? self::PUBLIC_READ : self::PRIVATE_ACCESS
		));

		return $result;
	}
1120535
def cp(src_path, dst_path, follow_links=False, recursive=True):
    
    successful = False
    try:
        if follow_links and os.path.islink(src_path):
            src_path = os.path.realpath(src_path)
        if follow_links and os.path.islink(dst_path):
            dst_path = os.path.realpath(dst_path)
        if os.path.isdir(src_path):
            if not recursive:
                return successful
            shutil.copytree(src_path, dst_path, symlinks=follow_links)
            successful = True
        elif os.path.exists(src_path):
            if os.path.isdir(dst_path):
                dst_path = os.path.join(dst_path, os.path.basename(src_path))
            shutil.copy2(src_path, dst_path)
            successful = True
        else:
            log.error('cp: source not found: %s' % src_path)
    except (OSError, TypeError) as error:
        log.error('cp: execute failed: %s => %s (%s)' % (src_path, dst_path, error))
    return successful
535969
def copy_file(src, dst, ignore=None):
   
   # Sanity checkpoint
   src = re.sub('[^\w/\-\.\*]', '', src)
   dst = re.sub('[^\w/\-\.\*]', '', dst)
   if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
      debug.log("Error: Copying file failed. Provided paths are invalid! src='%s' dst='%s'"%(src, dst))
   else:
      # Check destination
      check = False
      if dst[-1] == '/':
         if os.path.exists(dst):
            check = True # Valid Dir
         else:
            debug.log("Error: Copying file failed. Destination directory does not exist (%s)"%(dst)) #DEBUG
      elif os.path.exists(dst):
         if os.path.isdir(dst):
            check = True # Valid Dir
            dst += '/' # Add missing slash
         else:
            debug.log("Error: Copying file failed. %s exists!"%dst)
      elif os.path.exists(os.path.dirname(dst)):
         check = True # Valid file path
      else:
         debug.log("Error: Copying file failed. %s is an invalid distination!"%dst)
      if check:
         # Check source
         files = glob.glob(src)
         if ignore is not None: files = [fil for fil in files if not ignore in fil]
         if len(files) != 0:
            debug.log("Copying File(s)...", "Copy from %s"%src, "to %s"%dst) #DEBUG
            for file_ in files:
               # Check file exists
               if os.path.isfile(file_):
                  debug.log("Copying file: %s"%file_) #DEBUG
                  shutil.copy(file_, dst)
               else:
                  debug.log("Error: Copying file failed. %s is not a regular file!"%file_) #DEBUG
         else: debug.log("Error: Copying file failed. No files were found! (%s)"%src)
896821
public function copyDir($srcDir, $dstDir)
    {
        $this->returnCode = 'no';

        return $this->send('v-copy-fs-directory', $this->userName, $srcDir, $dstDir);
    }
756876
protected function copyFile($srcFilePath, $destFilePath)
    {
        $fileBody = file_get_contents($srcFilePath); // original

        if (empty($this->uploadsDirectCopy)) {
            // preparate image to remove injected code, etc
            $imagine = Image::getImagine();
            try {
                $image = $imagine->open($srcFilePath);
                $fileBody = $image->get($this->_format, []); // preprocessed image
            } catch (Exception $ex) {
              //$this->errmsg = Yii::t($this->tc, "Uploaded file '{file}' not an image", ['file' => $srcFilePath]);
                $this->errmsg = $ex->getMessage();
                Yii::error($this->errmsg);
                //return false;

                // show instead of return error
                //$fileBody = @file_get_contents($this->badImage);
                $image = $imagine->open($this->badImage);
                $fileBody = $image->get($this->_format, []);
            }
        }

        $destDir = dirname($destFilePath);
        if (!is_dir($destDir) && !@FileHelper::createDirectory($destDir)) {
         //$this->errmsg = Yii::t($this->tc, "Can't create destination folder '{dir}'", ['dir' => $destDir]);
           $this->errmsg = "Can't create destination folder '$destDir'";
           Yii::error($this->errmsg);
           return false;
        }

        $result = @file_put_contents($destFilePath, $fileBody, LOCK_EX);
        if ($result === false) {
         //$this->errmsg = Yii::t($this->tc, "Fail in file_put_contents('{from}', '...')", ['from' => $destFilePath]);
           $this->errmsg = "Fail in file_put_contents('$destFilePath', '...')";
           Yii::error($this->errmsg);
        }
        return $result;
    }
387569
public static File copy(String srcPath, String destPath, boolean isOverride) throws IORuntimeException {
		return copy(file(srcPath), file(destPath), isOverride);
	}
954442
public function extractArchive($srcFile, $dstDir)
    {
        $this->returnCode = 'no';

        return $this->send('v-extract-fs-archive', $this->userName, $srcFile, $dstDir);
    }
478013
public void copyFromLocalFile(boolean delSrc, boolean overwrite, 
                                Path[] srcs, Path dst)
    throws IOException {
    fs.copyFromLocalFile(delSrc, overwrite, srcs, dst);
  }
434160
@Deprecated
  public void copyFromLocalFile(Path src, Path dst)
    throws IOException {
    copyFromLocalFile(false, true, false, src, dst);
  }
246180
public static function uncompressFile($filepathSrc, $filepathDst = null)
	{
		if (!isset($filepathDst)) {
			$regex = '#^(.+).gz$#';
			$filepathDst = preg_replace($regex, '$1', $filepathSrc);
		} elseif (is_dir($filepathDst)) {
			$pathInfo = pathinfo($filepathSrc);
			$filename = preg_replace($filename, '$1', $pathInfo['filename']);
			$filepathDst = $pathInfo['dirname'].'/'.$filename;
		}
		$return = $filepathDst;
		if ($filepathDst == $filepathSrc) {
			// @todo
			$return = false;
		} elseif ($fpIn = gzopen($filepathSrc, 'rb')) {
			if ($fpOut = fopen($filepathDst, 'wb')) {
				while (!gzeof($fpIn)) {
					fwrite($fpOut, gzread($fpIn, 1024*512));
				}
			} else {
				$return = false;
			}
		} else {
			$return = false;
		}
		return $return;
	}
843181
protected static function copyDir($src, $dst, $mode=null) {
		if($mode === null)
			$mode = static::OVERRIDE;

		if(file_exists($dst)) {
			if($mode & static::MERGEDIR) {}
			elseif($mode & static::RENAME)
				$dst = static::getNewFilename($dst);
			elseif($mode & static::OVERRIDE)
				static::delete($dst);
		}

		$r = true;
		$dir = opendir($src);
		static::mkdir($dst);
		while(false !== ($file = readdir($dir))) {
			if(($file != '.') && ($file != '..'))
				$r = $r && static::copy($src.'/'.$file, $dst.'/'.$file, $mode);
		}
		closedir($dir);

		if($r !== false)
			return $dst;
		return false;
	}
389145
public function store_destfile_from_path($filepath) {
        if ($record = $this->get_file_record()) {
            $fs = get_file_storage();
            $existing = $fs->get_file(
                $record['contextid'],
                $record['component'],
                $record['filearea'],
                $record['itemid'],
                $record['filepath'],
                $record['filename']
            );
            if ($existing) {
                $existing->delete();
            }
            $file = $fs->create_file_from_pathname($record, $filepath);

            $this->raw_set('destfileid', $file->get_id());
        }

        return $this;
    }
122096
public void moveFromLocalFile(Path src, Path dst)
    throws IOException {
    copyFromLocalFile(true, true, false, src, dst);
  }
93552
def copy(srcpath, dstpath, overwrite=True):
    """"""
    # Handle bail conditions.
    if not op.exists(srcpath):
        return False
    if not overwrite:
        if op.isfile(dstpath):
            return False
        if op.isdir(dstpath):
            chkpath = op.join(dstpath, op.basename(srcpath))
            if op.isdir(chkpath) or op.isfile(chkpath):
                return False
    srcpath = op.abspath(srcpath)
    dstpath = op.abspath(dstpath)

    # Handle copying.
    if op.isdir(srcpath):
        dstdir = dstpath
        if op.isfile(dstpath):
            dstdir = op.dirname(dstpath)
        elif op.isdir(dstpath):
            # Make sure srcdir is copied INTO dstdir.
            dstdir = op.join(dstpath, op.basename(srcpath))
        makedirs(dstdir)
        for r,ds,fs in os.walk(srcpath):
            basedir = r.replace(srcpath, "").rstrip(os.sep).strip(os.sep)
            curdir = op.join(dstdir, basedir)
            makedirs(curdir)
            for f in fs:
                if not copy(op.join(r,f), op.join(curdir, f), overwrite=overwrite):
                    return False
    elif op.isfile(srcpath):
        makedirs(dstpath)
        shutil.copy2(srcpath, dstpath)

    return op.exists(dstpath)
599103
private function copy($src, $dst, $force = false, $chmod = 0777) {
        $path = pathinfo($dst);
        if ( ! is_dir($path['dirname']) || $force) {
            @mkdir($path['dirname'], $chmod, true);
        }
        if ( ! file_exists($dst) || $force) {
            @copy($src, $dst);
        }
    }
1167111
public static function copyDir($src, $dst)
    {
        if (is_link($src)) {
            symlink(readlink($src), $dst);
        } elseif (is_dir($src)) {
            if (is_dir($dst) === false) {
                mkdir($dst, 0775, true);
            }
            // copy files recursive
            foreach (scandir($src) as $file) {
                if ($file != '.' && $file != '..') {
                    FileSystem::copyDir("$src/$file", "$dst/$file");
                }
            }

        } elseif (is_file($src)) {
            copy($src, $dst);
        } else {
            // do nothing, we didn't have a directory to copy
        }
    }