Creates copy of an object and delete the original.
@param  string $origFilePath	  Key name of the source object
@param  string $targetFilePath New file path
181719
public function moveFile($origFilePath, $targetFilePath) {
		$this->copyFile($this->getBucket() . "/" . $origFilePath, $targetFilePath);
		$this->deleteFile($origFilePath);
	}
56780
private function validateRegisterFilepath($registerFilepath)
    {
        if (false === file_exists($registerFilepath)) {
            throw new \InvalidArgumentException("File $registerFilepath does not exist");
        }

        $yamlPattern = '#' . '(.*)\.yml$' . '#';

        $isAYamlFile = preg_match($yamlPattern, $registerFilepath);
        if (false === $isAYamlFile) {
            throw new \InvalidArgumentException("File $registerFilepath is not a YAML file");
        }
    }
254262
def copy_target_dir(cls, orig_dir, dest_dir, roi_baseline, extracopy):
        
        try:
            os.makedirs(dest_dir)
        except OSError:
            pass

        copyfiles = ['%s.fits' % roi_baseline,
                     '%s.npy' % roi_baseline,
                     '%s_*.xml' % roi_baseline] + cls.copyfiles
        if isinstance(extracopy, list):
            copyfiles += extracopy

        cls.copy_analysis_files(orig_dir, dest_dir, copyfiles)
566173
public function copyForDeployment($targetPath, $development = true)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->loadXML($this->dom->saveXML());

        $xpath = new \DOMXpath($dom);
        $xpath->registerNamespace('sc', $dom->lookupNamespaceUri($dom->namespaceURI));
        $settings = $xpath->evaluate('//sc:ConfigurationSettings/sc:Setting[@name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"]');
        foreach ($settings as $setting) {
            if ($development) {
                $setting->setAttribute('value', 'UseDevelopmentStorage=true');
            } else
                if (strlen($setting->getAttribute('value')) === 0) {
                    if ($this->storage) {
                        $setting->setAttribute('value', sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $this->storage['accountName'], $this->storage['accountKey']));
                    } else {
                        throw new \RuntimeException(<<<EXC
ServiceConfiguration.csdef: Missing value for
'Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString'.

You have to modify the app/azure/ServiceConfiguration.csdef to contain
a value for the diagnostics connection string or better configure
'windows_azure_distribution.diagnostics.accountName' and
'windows_azure_distribution.diagnostics.accountKey' in your
app/config/config.yml

If you don't want to enable diagnostics you should delete the
connection string elements from ServiceConfiguration.csdef file.
EXC
);
                    }
                }
        }

        $dom->save($targetPath . '/ServiceConfiguration.cscfg');
    }
572831
static void copyFileFromResources(String sourcePath, String destPath) throws IOException {
        LOGGER.entering(new Object[] { sourcePath, destPath });

        File downloadFile = new File(destPath);

        if (!downloadFile.exists()) {
            InputStream stream = JarSpawner.class.getResourceAsStream(sourcePath);
            FileUtils.copyInputStreamToFile(stream, downloadFile);
            LOGGER.fine("File copied to " + destPath);
        }
        LOGGER.exiting();
    }
1059885
public function copyFolder($originalPath, $newPath)
    {
        $disk = $this->getStorageDisk();

        $copyDirectory = function ($srcPath, $destPath) use (&$copyDirectory, $disk) {
            $srcPath = self::validatePath($srcPath);
            $fullSrcPath = $this->getMediaPath($srcPath);

            $destPath = self::validatePath($destPath);
            $fullDestPath = $this->getMediaPath($destPath);

            if (!$disk->makeDirectory($fullDestPath)) {
                return false;
            }

            $folderContents = $this->scanFolderContents($fullSrcPath);

            foreach ($folderContents['folders'] as $dirInfo) {
                if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
                    return false;
                }
            }

            foreach ($folderContents['files'] as $fileInfo) {
                $fullFileSrcPath = $this->getMediaPath($fileInfo->path);

                if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
                    return false;
                }
            }

            return true;
        };

        return $copyDirectory($originalPath, $newPath);
    }
1097431
public function copy($source, $target)
    {
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);

        if (!file_exists($target)) {
            mkdir($target, 0777, true);
        }

        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                if (!file_exists($targetPath)) {
                    mkdir($targetPath);
                }
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
977966
public static void copyResourceToFile(String resourceAbsoluteClassPath, File targetFile) throws IOException {
        InputStream is = ResourceUtil.class.getResourceAsStream(resourceAbsoluteClassPath);
        if (is == null) {
            throw new IOException("Resource not found! " + resourceAbsoluteClassPath);
        }
        OutputStream os = null;
        try {
            os = new FileOutputStream(targetFile);
            byte[] buffer = new byte[2048];
            int length;
            while ((length = is.read(buffer)) != -1) {
                os.write(buffer, 0, length);
            }
            os.flush();
        } finally {
            try {
                is.close();
                if (os != null) {
                    os.close();
                }
            } catch (Exception ignore) {
                // ignore
            }
        }
    }
173198
def remove_path(target_path):
    
    if os.path.isdir(target_path):
        shutil.rmtree(target_path)
    else:
        os.unlink(target_path)
1233025
protected static function _replace(&$target, $path, $options)
    {
        $pathE    = explode('.', $path);
        $path     = array_shift($pathE);
        $fragment = join('.', $pathE);

        if (!empty($pathE)) {
            self::_replace($target[$path], $fragment, $options);
        } else {
            $target[$path] = self::_merge($target[$path], $options);
        }
    }
1289465
public function copyTo(string $fullPath) : IFile
    {
        if ($this->copyCallback) {
            return call_user_func($this->copyCallback, $fullPath);
        }

        return $this->file;
    }
41417
public static boolean delete(Path targetPath) {
        debug(log, "delete", targetPath);
        try {
            Files.delete(targetPath);
            return true;
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
                    "delete", targetPath);
        }
    }
787774
static function copyFile($source, $target, $overwrite = true)
    {
        if (!file_exists($source)) return false;
        if (file_exists($target) && $overwrite == false) return false;
        elseif (file_exists($target) && $overwrite == true) {
            if (!unlink($target)) return false;
        }
        $targetDir = dirname($target);
        if (!self::createDirectory($targetDir)) return false;
        return copy($source, $target);
    }
281604
public function serialize($targetFile,$data)
    {
        $contents = serialize($data);
        $this->putFileContents($targetFile,$contents);
    }
315883
public function copyFromDFS( $srcFilePath, $dstFilePath = false )
    {
        return $this->getHandler( $srcFilePath )->copyFromDFS( $srcFilePath, $dstFilePath );
    }
204999
private void copyFile(String path, File dest) {
        String resourceName= "native/" + path;
        try
        {
            LOG.debug("Copy from resource <"+resourceName+"> to target <"+dest.getAbsolutePath()+">");
            if (copy(getClass().getResourceAsStream(resourceName), dest.getAbsolutePath()))
            {
                if (dest.exists())
                {
                    LOG.debug("Target <"+dest.getAbsolutePath()+"> exists");
                }
                else
                {
                    LOG.fatal("Target <"+dest.getAbsolutePath()+"> does not exist");
                }
            }
            else
            {
                LOG.fatal("Copy resource to target <"+dest.getAbsolutePath()+"> failed");
            }
        }
        catch (NullPointerException ex)
        {
            LOG.error("Could not find ffmpeg executable for "+resourceName+" is the correct platform jar included?");
            throw ex;
        }
    }
181233
public static void copyFile (String sourceFileName, String targetFileName) throws OSHelperException {
		File sourceFile = new File (sourceFileName);
		File targetFile = new File (targetFileName);

		FileReader sourceReader;
		try {
			sourceReader = new FileReader (sourceFile);
		} catch (FileNotFoundException ex) {
			throw new OSHelperException ("Received an FileNotFoundException when trying to open source file " + sourceFileName + ".", ex);
		}

		FileWriter targetWriter;
		try {
			targetWriter = new FileWriter (targetFile);
		} catch (IOException ex) {
			throw new OSHelperException ("Received an IOException when trying to open target file " + targetFileName + ".", ex);
		}


		int readByteInInt = 0;
		while (readByteInInt != -1) {

			try {
				readByteInInt = sourceReader.read ();
			} catch (IOException ex) {
				throw new OSHelperException ("Received an IOException when trying to read from source file " + sourceFileName + ".", ex);
			}
			if (readByteInInt != -1) {
				try {
					targetWriter.write (readByteInInt);
				} catch (IOException ex) {
					throw new OSHelperException ("Received an IOException when trying to write to target file " + targetFileName + ".", ex);
				}
			}
		}

		try {
			sourceReader.close ();
		} catch (IOException ex) {
			throw new OSHelperException ("Received an IOException when trying to close reader for source file " + sourceFileName + ".", ex);
		}
		try {
			targetWriter.close ();
		} catch (IOException ex) {
			throw new OSHelperException ("Received an IOException when trying to close reader for target file " + targetFileName + ".", ex);
		}

	}