本文整理汇总了PHP中PhingFile::isFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::isFile方法的具体用法?PHP PhingFile::isFile怎么用?PHP PhingFile::isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::isFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyFile
/**
* Copies a file using filter chains.
*
* @param PhingFile $sourceFile
* @param PhingFile $destFile
* @param boolean $overwrite
* @param boolean $preserveLastModified
* @param array $filterChains
* @param Project $project
* @return void
*/
function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project)
{
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists() && $destFile->isFile()) {
$destFile->delete();
}
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null && !$parent->exists()) {
$parent->mkdirs();
}
if (is_array($filterChains) && !empty($filterChains)) {
$in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
$out = new BufferedWriter(new FileWriter($destFile));
// New read() methods returns a big buffer.
while (-1 !== ($buffer = $in->read())) {
// -1 indicates EOF
$out->write($buffer);
}
if ($in !== null) {
$in->close();
}
if ($out !== null) {
$out->close();
}
} else {
// simple copy (no filtering)
$sourceFile->copyTo($destFile);
}
if ($preserveLastModified) {
$destFile->setLastModified($sourceFile->lastModified());
}
}
}
示例2: main
/**
* create the directory and all parents
*
* @throws BuildException if dir is somehow invalid, or creation failed.
*/
public function main()
{
if ($this->dir === null) {
throw new BuildException("dir attribute is required", $this->location);
}
if ($this->dir->isFile()) {
throw new BuildException("Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath());
}
if (!$this->dir->exists()) {
$result = $this->dir->mkdirs($this->mode);
if (!$result) {
if ($this->dir->exists()) {
$this->log("A different process or task has already created " . $this->dir->getAbsolutePath());
return;
}
$msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason";
throw new BuildException($msg, $this->location);
}
$this->log("Created dir: " . $this->dir->getAbsolutePath());
}
}
示例3: copyFile
/**
* Copies a file using filter chains.
*
* @param PhingFile $sourceFile
* @param PhingFile $destFile
* @param boolean $overwrite
* @param boolean $preserveLastModified
* @param array $filterChains
* @param Project $project
* @param integer $mode
* @param bool $preservePermissions
*
* @throws Exception
* @throws IOException
* @return void
*/
public function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project, $mode = 0755, $preservePermissions = true)
{
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists() && $destFile->isFile()) {
$destFile->delete();
}
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null && !$parent->exists()) {
// Setting source directory permissions to target
// (On permissions preservation, the target directory permissions
// will be inherited from the source directory, otherwise the 'mode'
// will be used)
$dirMode = $preservePermissions ? $sourceFile->getParentFile()->getMode() : $mode;
$parent->mkdirs($dirMode);
}
if (is_array($filterChains) && !empty($filterChains)) {
$in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
$out = new BufferedWriter(new FileWriter($destFile));
// New read() methods returns a big buffer.
while (-1 !== ($buffer = $in->read())) {
// -1 indicates EOF
$out->write($buffer);
}
if ($in !== null) {
$in->close();
}
if ($out !== null) {
$out->close();
}
// Set/Copy the permissions on the target
if ($preservePermissions === true) {
$destFile->setMode($sourceFile->getMode());
}
} else {
// simple copy (no filtering)
$sourceFile->copyTo($destFile);
// By default, PHP::Copy also copies the file permissions. Therefore,
// re-setting the mode with the "user file-creation mask" information.
if ($preservePermissions === false) {
$destFile->setMode(FileUtils::getDefaultFileCreationMask(false, true));
}
}
if ($preserveLastModified && !$destFile->isLink()) {
$destFile->setLastModified($sourceFile->lastModified());
}
}
}
示例4: _checkFile1
private function _checkFile1(PhingFile $file)
{
// Resolve symbolic links
if ($this->followSymlinks && $file->isLink()) {
$file = new PhingFile($file->getLinkTarget());
}
if ($this->type !== null) {
if ($this->type === "dir") {
return $file->isDirectory();
} else {
if ($this->type === "file") {
return $file->isFile();
}
}
}
return $file->exists();
}
示例5: _verifyManifest
/**
* @return void
*/
protected function _verifyManifest()
{
if (!$this->_file->isFile() || !$this->_file->canRead()) {
throw new BuildException(
'Failed reading from manifest file',
$this->location
);
}
$manifest = array ();
$fp = fopen($this->_file, 'r');
while (true == ($line = trim(fgets($fp)))) {
list ($path, $hash) = explode("\t", $line);
$manifest[$path] = $hash;
}
fclose($fp);
$verified = true;
// Check for files present which are not in the manifest
$filesNotInManifest = array_keys(array_diff_key($manifest, $this->_hashes));
if (!empty ($filesNotInManifest)) {
$verified = false;
$this->log(
'There are ' . count($filesNotInManifest) . ' files present which are not listed in the manifest',
PROJECT::MSG_WARN
);
foreach ($filesNotInManifest as $path) {
$this->log(
'Extra file: ' . $path,
PROJECT::MSG_WARN
);
}
unset ($path);
}
unset ($filesNotInManifest);
// Check for files listed in the manifest which are not present
$filesNotPresent = array_keys(array_diff_key($this->_hashes, $manifest));
if (!empty ($filesNotPresent)) {
$verified = false;
$this->log(
'There are ' . count($filesNotPresent) . ' files listed in the manifest which are not present',
PROJECT::MSG_WARN
);
foreach ($filesNotPresent as $path) {
$this->log(
'Missing file: ' . $path,
PROJECT::MSG_WARN
);
}
unset ($path);
}
unset ($filesNotPresent);
// Compare manifest hashes with the computed hashes
$filesPresent = array_keys(array_intersect_key($manifest, $this->_hashes));
foreach ($filesPresent as $path) {
if ($manifest[$path] != $this->_hashes[$path]) {
$verified = false;
$this->log(
'Hashes do not match: ' . $path,
PROJECT::MSG_WARN
);
}
}
unset ($filesPresent);
if (!$verified) {
throw new BuildException(
'Manifest verification failed'
);
}
$this->log('Manifest verification successful');
}
示例6: _checkFile1
private function _checkFile1(PhingFile $file)
{
if ($this->type !== null) {
if ($this->type === "dir") {
return $file->isDirectory();
} else {
if ($this->type === "file") {
return $file->isFile();
}
}
}
return $file->exists();
}
示例7: _checkFile1
/**
* @param PhingFile $file
* @return bool
* @throws IOException
*/
private function _checkFile1(PhingFile $file)
{
// Resolve symbolic links
if ($this->followSymlinks && $file->isLink()) {
$linkTarget = new PhingFile($file->getLinkTarget());
if ($linkTarget->isAbsolute()) {
$file = $linkTarget;
} else {
$fs = FileSystem::getFileSystem();
$file = new PhingFile($fs->resolve($fs->normalize($file->getParent()), $fs->normalize($file->getLinkTarget())));
}
}
if ($this->type !== null) {
if ($this->type === "dir") {
return $file->isDirectory();
} else {
if ($this->type === "file") {
return $file->isFile();
}
}
}
return $file->exists();
}
示例8: main
/**
* Do the work
*
* @throws BuildException
*/
public function main()
{
$this->verifyConfiguration();
$this->prepareEncoderCommand();
try {
if (empty($this->filesets)) {
throw new BuildException("You must supply nested fileset.", $this->getLocation());
}
$encodedFilesCounter = 0;
foreach ($this->filesets as $fs) {
/* @var $fs FileSet */
/* @var $fsBasedir PhingFile */
$fsBasedir = $fs->getDir($this->project)->getAbsolutePath();
$files = $fs->getFiles($this->project, false);
foreach ($files as $file) {
$f = new PhingFile($fsBasedir, $file);
if ($f->isFile()) {
$path = $f->getAbsolutePath();
$this->log("Encoding " . $path, Project::MSG_VERBOSE);
$this->encodeFile($path);
$encodedFilesCounter++;
}
}
}
$this->log("Encoded files: " . $encodedFilesCounter);
} catch (IOException $ioe) {
$msg = "Problem encoding files: " . $ioe->getMessage();
throw new BuildException($msg, $ioe, $this->getLocation());
}
}
示例9: PhingFile
function _checkFile()
{
if ($this->filepath === null) {
return $this->_checkFile1($this->file);
} else {
$paths = $this->filepath->listDir();
for ($i = 0, $pcnt = count($paths); $i < $pcnt; $i++) {
$this->log("Searching " . $paths[$i], PROJECT_MSG_VERBOSE);
$tmp = new PhingFile($paths[$i], $this->file->getName());
if ($tmp->isFile()) {
return true;
}
}
}
return false;
}