压缩文件
@param File $distFile
@param File $sourceFile
164648
public static function compress(File $distFile, File $sourceFile) {
        $distStream = new static();
        $distStream->openWrite($distFile);
        $srcStream = new Stream($sourceFile);
        $srcStream->openRead();
        while (!$srcStream->isEnd()) {
            $distStream->write($srcStream->read(1024 * 256));
        }
        $srcStream->close();
        $distStream->close();
    }
606414
public static IFileContentResultBean compareFiles(final File sourceFile,
		final File fileToCompare)
	{
		return compareFiles(sourceFile, fileToCompare, true, false, false, true, false, true);
	}
150305
protected function doGet($sourceFile, $destinationFile)
    {
        $connection = $this->connection;
        $ftpMode = $this->getParam('transfer_mode');
        $createMask = $this->getParam('create_mask');

        return $this->retry(function () use ($connection, $destinationFile, $sourceFile, $ftpMode, $createMask) {
            $localDir = dirname($destinationFile);

            if (!file_exists($localDir)) {
                mkdir($localDir, $createMask, true);
            }

            $res = @ftp_get($connection, $destinationFile, $sourceFile, $ftpMode);

            if (false === $res) {
                throw new \RuntimeException("Couldn't copy file: ".$sourceFile);
            }
        });
    }
206682
public static void renameTo(String sourceFile, String destFile) {
        renameTo(new File(sourceFile), new File(destFile));
    }
1241964
public static function convertJsonToIni( $sourceFile, $targetFile )
	{
		$data	= self::loadJson( $sourceFile );
		return self::saveIni( $targetFile, $data );
	}
1001753
public void addFile(String sourceFolder, String name, ClassLoaderFile file) {
		Assert.notNull(sourceFolder, "SourceFolder must not be null");
		Assert.notNull(name, "Name must not be null");
		Assert.notNull(file, "File must not be null");
		removeAll(name);
		getOrCreateSourceFolder(sourceFolder).add(name, file);
	}
271380
public function validate(File $file, $typeName, $sourceFilePath = null)
	{
		$name = $file->getFileName();
		$fileNameHelper = new Helpers\FileNameValidationHelper();
		$result = $fileNameHelper->validate($name);
		
		if( ! $result) {
			$message = $fileNameHelper->getErrorMessage();
			
			throw new Exception\UploadFilterException(self::EXCEPTION_MESSAGE_KEY, $message);
		}
	}
779560
public function copyFile($source, $target, $file)
    {
        $this->mkDir($target);
        if (file_exists($source.$file)) {
            copy($source.$file, $target.$file);
        }
    }
445113
public static boolean copyFile(String srcFile, String destFile) {
		boolean flag = false;
		FileInputStream fin = null;
		FileOutputStream fout = null;
		FileChannel fcin = null;
		FileChannel fcout = null;
		try {
			// 获取源文件和目标文件的输入输出流
			fin = new FileInputStream(srcFile);
			fout = new FileOutputStream(destFile);
			// 获取输入输出通道
			fcin = fin.getChannel();
			fcout = fout.getChannel();
			// 创建缓冲区
			ByteBuffer buffer = ByteBuffer.allocate(1024);
			while (true) {
				// clear方法重设缓冲区，使它可以接受读入的数据
				buffer.clear();
				// 从输入通道中将数据读到缓冲区
				int r = fcin.read(buffer);
				// read方法返回读取的字节数，可能为零，如果该通道已到达流的末尾，则返回-1
				if (r == -1) {
					flag = true;
					break;
				}
				// flip方法让缓冲区可以将新读入的数据写入另一个通道
				buffer.flip();
				// 从输出通道中将数据写入缓冲区
				fcout.write(buffer);
			}
			fout.flush();
		} catch (IOException e) {
			LogUtil.writeErrorLog("CopyFile fail", e);
		} finally {
			try {
				if (null != fin)
					fin.close();
				if (null != fout)
					fout.close();
				if (null != fcin)
					fcin.close();
				if (null != fcout)
					fcout.close();
			} catch (IOException ex) {
				LogUtil.writeErrorLog("Releases any system resources fail", ex);
			}
		}
		return flag;
	}
1303813
public static void updateFileFromFile(final File sourceFile, final String destinationFilePath) throws
        UpdateException {
        if (!sourceFile.exists()) {
            throw new UpdateException("Source file does not exist: " + sourceFile);
        }
        if (!sourceFile.isFile()) {
            throw new UpdateException("Not a file: " + sourceFile);
        }
        if (sourceFile.length() < 1) {
            throw new UpdateException("Source file is empty: " + sourceFile);
        }

        try {
            updateFileFromInputStream(new FileInputStream(sourceFile), destinationFilePath);
        } catch (IOException e) {
            throw new UpdateException("Unable to update file: " + e.getMessage(), e);
        }
    }
849631
private function extract(string $sourceFile, string $destinationDir): self
    {
        $p = new \PharData($sourceFile);
        $p->extractTo($destinationDir);

        return $this;
    }
397246
public static boolean compareFilesByAbsolutePath(final File sourceFile,
		final File fileToCompare)
	{
		return CompareFileExtensions
			.compareFiles(sourceFile, fileToCompare, false, true, true, true, true, true)
			.getAbsolutePathEquality();
	}
934217
public function validateLicenseFile($originFile)
	{
		$fileContents = (string) file_get_contents($this->originPath . '/' . $originFile);

		if (md5($fileContents) != 'e060338598cd2cd6b8503733fdd40a11')
		{
			$this->output->addMessage(Output::FATAL, 'License must be: GNU GENERAL PUBLIC LICENSE Version 2, June 1991', $originFile);
		}
	}
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);
		}

	}
986596
public function upload($sourceFile, $destinationFile)
    {
        Service::$log->msg('Upload to S3 started: ' . $sourceFile);
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $destinationFile;
        $this->s3Instance->multipartUpload($this->s3Config->Bucket, $destinationFile, $sourceFile, 3);
        Service::$log->msg('Upload ended');

        return $destinationFile;
    }
69211
public void transform(final File inputFile, final List<XMLFilter> filters) throws DITAOTException {
        final File outputFile = new File(inputFile.getAbsolutePath() + FILE_EXTENSION_TEMP);
        transformFile(inputFile, outputFile, filters);
        try {
            deleteQuietly(inputFile);
            moveFile(outputFile, inputFile);
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            throw new DITAOTException("Failed to replace " + inputFile + ": " + e.getMessage());
        }
    }
1268000
public function storeFileData(File $file, $sourceFilePath)
	{
		$this->validateFileUpload($file, $sourceFilePath);

		$this->createBothFoldersInFileSystem($file);

		$filePath = $this->getFilesystemPath($file);

		if ( ! copy($sourceFilePath, $filePath)) {
			throw new Exception\RuntimeException('Failed to copy file form "' . $sourceFilePath . '" to "' . $filePath . '"');
		} else {
			chmod($filePath, $this->fileAccessMode);
		}
	}