本文整理汇总了PHP中PhingFile::setLastModified方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::setLastModified方法的具体用法?PHP PhingFile::setLastModified怎么用?PHP PhingFile::setLastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::setLastModified方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doWork
/**
* Actually copies the files
*
* @return void
* @throws BuildException
*/
protected function doWork()
{
// These "slots" allow filters to retrieve information about the currently-being-process files
$fromSlot = $this->getRegisterSlot("currentFromFile");
$fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
$toSlot = $this->getRegisterSlot("currentToFile");
$toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
$mapSize = count($this->fileCopyMap);
$total = $mapSize;
// handle empty dirs if appropriate
if ($this->includeEmpty) {
$count = 0;
foreach ($this->dirCopyMap as $srcdir => $destdir) {
$s = new PhingFile((string) $srcdir);
$d = new PhingFile((string) $destdir);
if (!$d->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 = $this->preservePermissions ? $s->getMode() : $this->mode;
// Directory creation with specific permission mode
if (!$d->mkdirs($dirMode)) {
$this->logError("Unable to create directory " . $d->__toString());
} else {
if ($this->preserveLMT) {
$d->setLastModified($s->lastModified());
}
$count++;
}
}
}
if ($count > 0) {
$this->log("Created " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " in " . $this->destDir->getAbsolutePath());
}
}
if ($mapSize == 0) {
return;
}
$this->log("Copying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
// walks the map and actually copies the files
$count = 0;
foreach ($this->fileCopyMap as $from => $toFiles) {
if (is_array($toFiles)) {
foreach ($toFiles as $to) {
$this->copyToSingleDestination($from, $to, $fromSlot, $fromBasenameSlot, $toSlot, $toBasenameSlot, $count, $total);
}
} else {
$this->copyToSingleDestination($from, $toFiles, $fromSlot, $fromBasenameSlot, $toSlot, $toBasenameSlot, $count, $total);
}
}
}
示例2: doWork
/**
* Actually copies the files
*
* @access private
* @return void
* @throws BuildException
*/
protected function doWork()
{
// These "slots" allow filters to retrieve information about the currently-being-process files
$fromSlot = $this->getRegisterSlot("currentFromFile");
$fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
$toSlot = $this->getRegisterSlot("currentToFile");
$toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
$mapSize = count($this->fileCopyMap);
$total = $mapSize;
// handle empty dirs if appropriate
if ($this->includeEmpty) {
$count = 0;
foreach ($this->dirCopyMap as $srcdir => $destdir) {
$s = new PhingFile((string) $srcdir);
$d = new PhingFile((string) $destdir);
if (!$d->exists()) {
if (!$d->mkdirs()) {
$this->logError("Unable to create directory " . $d->__toString());
} else {
if ($this->preserveLMT) {
$d->setLastModified($s->lastModified());
}
$count++;
}
}
}
if ($count > 0) {
$this->log("Created " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " in " . $this->destDir->getAbsolutePath());
}
}
if ($mapSize > 0) {
$this->log("Copying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
// walks the map and actually copies the files
$count = 0;
foreach ($this->fileCopyMap as $from => $to) {
if ($from === $to) {
$this->log("Skipping self-copy of " . $from, $this->verbosity);
$total--;
continue;
}
$this->log("From " . $from . " to " . $to, $this->verbosity);
try {
// try to copy file
$fromFile = new PhingFile($from);
$toFile = new PhingFile($to);
$fromSlot->setValue($fromFile->getPath());
$fromBasenameSlot->setValue($fromFile->getName());
$toSlot->setValue($toFile->getPath());
$toBasenameSlot->setValue($toFile->getName());
$this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject(), $this->mode);
$count++;
} catch (IOException $ioe) {
$this->logError("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage());
}
}
}
}
示例3: _writeFile
/**
* Writing a file.
*
* @param PhingFile $file The file to write
* @param mixed $content The file's content
* @return void
* @throws BuildException
* @access protected
**/
protected function _writeFile(PhingFile $file, $content)
{
if ($this->_preserveLastModified) {
$lastModified = $file->lastModified();
}
$output = new FileWriter($file);
$output->write($content);
$output->close();
if ($this->_preserveLastModified) {
$file->setLastModified($lastModified);
}
}