本文整理汇总了PHP中PhingFile::mkdirs方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::mkdirs方法的具体用法?PHP PhingFile::mkdirs怎么用?PHP PhingFile::mkdirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::mkdirs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
if (empty($this->filesets)) {
throw new BuildException("You must specify a file or fileset(s).");
}
if (empty($this->_compilePath)) {
throw new BuildException("You must specify location for compiled templates.");
}
date_default_timezone_set("America/New_York");
$project = $this->getProject();
$this->_count = $this->_total = 0;
$smartyCompilePath = new PhingFile($this->_compilePath);
if (!$smartyCompilePath->exists()) {
$this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
if (!$smartyCompilePath->mkdirs()) {
throw new BuildException("Error creating compile path for Smarty in " . $this->_compilePath);
}
}
$this->_smarty = new Smarty();
$this->_smarty->use_sub_dirs = true;
$this->_smarty->compile_dir = $smartyCompilePath;
$this->_smarty->plugins_dir[] = $this->_pluginsPath;
$this->_smarty->force_compile = $this->_forceCompile;
// process filesets
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$this->_compile($fromDir, $srcFiles);
}
$this->log("Compiled " . $this->_count . " out of " . $this->_total . " Smarty templates");
}
示例2: setOutputDirectory
/**
* Set the sqldbmap.
* @param PhingFile $sqldbmap The db map.
*/
public function setOutputDirectory(PhingFile $out)
{
if (!$out->exists()) {
$out->mkdirs();
}
$this->outDir = $out;
}
示例3: main
public function main()
{
/**
* Find PHPLoc
*/
if (!@(include_once 'SebastianBergmann/PHPLOC/Analyser.php')) {
throw new BuildException('PHPLocTask depends on PHPLoc being installed ' . 'and on include_path.', $this->getLocation());
}
$this->_validateProperties();
if (!is_null($this->reportDirectory) && !is_dir($this->reportDirectory)) {
$reportOutputDir = new PhingFile($this->reportDirectory);
$logMessage = "Report output directory doesn't exist, creating: " . $reportOutputDir->getAbsolutePath() . '.';
$this->log($logMessage);
$reportOutputDir->mkdirs();
}
if ($this->reportType !== 'cli') {
$this->reportFileName .= '.' . trim($this->reportType);
}
if (count($this->fileSets) > 0) {
$project = $this->getProject();
foreach ($this->fileSets as $fileSet) {
$directoryScanner = $fileSet->getDirectoryScanner($project);
$files = $directoryScanner->getIncludedFiles();
$directory = $fileSet->getDir($this->project)->getPath();
foreach ($files as $file) {
if ($this->isFileSuffixSet($file)) {
$this->filesToCheck[] = $directory . DIRECTORY_SEPARATOR . $file;
}
}
}
$this->filesToCheck = array_unique($this->filesToCheck);
}
$this->runPhpLocCheck();
}
示例4: setTmpDir
public function setTmpDir(PhingFile $dir)
{
if (!$dir->exists()) {
$dir->mkdirs();
}
$this->tmpDir = $dir->getAbsolutePath();
}
示例5: createDirectories
private function createDirectories($path)
{
$f = new PhingFile($path);
if (!$f->exists()) {
$f->mkdirs();
}
}
示例6: setToDir
/**
* Sets output directory
* @param string $toDir
*/
public function setToDir($toDir)
{
if (!is_dir($toDir)) {
$toDir = new PhingFile($toDir);
$toDir->mkdirs();
}
$this->toDir = $toDir;
}
示例7: ensureDirExists
/**
* Utility method to create directory for package if it doesn't already exist.
* @param string $path The [relative] package path.
* @throws BuildException - if there is an error creating directories
*/
protected function ensureDirExists($path)
{
$f = new PhingFile($this->getOutputDirectory(), $path);
if (!$f->exists()) {
if (!$f->mkdirs()) {
throw new BuildException("Error creating directories: " . $f->getPath());
}
}
}
示例8: 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());
}
}
示例9: setOutputDirectory
/**
* [REQUIRED] Set the output directory. It will be
* created if it doesn't exist.
* @param PhingFile $outputDirectory
* @return void
* @throws Exception
*/
public function setOutputDirectory(PhingFile $outputDirectory)
{
try {
if (!$outputDirectory->exists()) {
$this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE);
if (!$outputDirectory->mkdirs()) {
throw new IOException("Unable to create Ouptut directory: " . $outputDirectory->getAbsolutePath());
}
}
$this->outputDirectory = $outputDirectory->getCanonicalPath();
} catch (IOException $ioe) {
throw new BuildException($ioe);
}
}
示例10: main
/**
* @return void
*/
public function main()
{
$this->_checkTargetDir();
/* @var $fileSet FileSet */
foreach ($this->_fileSets as $fileSet) {
$files = $fileSet->getDirectoryScanner($this->project)
->getIncludedFiles();
foreach ($files as $file) {
$targetDir = new PhingFile($this->_targetDir, dirname($file));
if (!$targetDir->exists()) {
$targetDir->mkdirs();
}
unset ($targetDir);
$source = new PhingFile(
$fileSet->getDir($this->project),
$file
);
$target = new PhingFile(
$this->_targetDir,
str_replace('.less', '.css', $file)
);
$this->log("Processing ${file}");
try {
$lessc = new lessc($source->getAbsolutePath());
file_put_contents(
$target->getAbsolutePath(),
$lessc->parse()
);
} catch (Exception $e) {
$this->log("Failed processing ${file}!", Project::MSG_ERR);
$this->log($e->getMessage(), Project::MSG_DEBUG);
}
}
}
}
示例11: transform
private function transform(DOMDocument $document)
{
$dir = new PhingFile($this->toDir);
if (!$dir->exists() && !$dir->mkdirs()) {
throw new BuildException("Unable to create '" . $this->toDir . "'");
}
$xslfile = $this->getStyleSheet();
$xsl = new DOMDocument();
$xsl->load($xslfile->getAbsolutePath());
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
if ($this->format == "noframes") {
$writer = new FileWriter(new PhingFile($this->toDir, "checkstyle-noframes.html"));
$writer->write($proc->transformToXML($document));
$writer->close();
} else {
ExtendedFileStream::registerStream();
// no output for the framed report
// it's all done by extension...
$dir = new PhingFile($this->toDir);
$proc->setParameter('', 'output.dir', $dir->getAbsolutePath());
$proc->transformToXML($document);
}
}
示例12: validateProperties
/**
* @throws BuildException
*/
private function validateProperties()
{
if ($this->fileToCheck === null && count($this->fileSets) === 0) {
throw new BuildException('Missing either a nested fileset or the attribute "file" set.');
}
if ($this->fileToCheck !== null) {
if (!file_exists($this->fileToCheck)) {
throw new BuildException("File to check doesn't exist.");
}
if (!$this->isFileSuffixSet($this->fileToCheck)) {
throw new BuildException('Suffix of file to check is not defined in "suffixes" attribute.');
}
if (count($this->fileSets) > 0) {
throw new BuildException('Either use a nested fileset or "file" attribute; not both.');
}
}
if (count($this->suffixesToCheck) === 0) {
throw new BuildException('No file suffix defined.');
}
if (count($this->formatterElements) == 0) {
if ($this->reportType === null) {
throw new BuildException('No report type or formatters defined.');
}
if ($this->reportType !== null && !in_array($this->reportType, $this->acceptedReportTypes)) {
throw new BuildException('Unaccepted report type defined.');
}
if ($this->reportType !== 'cli' && $this->reportDirectory === null) {
throw new BuildException('No report output directory defined.');
}
if ($this->reportDirectory !== null && !is_dir($this->reportDirectory)) {
$reportOutputDir = new PhingFile($this->reportDirectory);
$logMessage = "Report output directory doesn't exist, creating: " . $reportOutputDir->getAbsolutePath() . '.';
$this->log($logMessage);
$reportOutputDir->mkdirs();
}
if ($this->reportType !== 'cli') {
$this->reportFileName .= '.' . $this->reportType;
}
$formatterElement = new PHPLocFormatterElement();
$formatterElement->setType($this->reportType);
$formatterElement->setUseFile($this->reportDirectory !== null);
$formatterElement->setToDir($this->reportDirectory);
$formatterElement->setOutfile($this->reportFileName);
$this->formatterElements[] = $formatterElement;
}
}
示例13: main
public function main()
{
$this->loadDependencies();
$this->validateProperties();
if ($this->reportDirectory !== null && !is_dir($this->reportDirectory)) {
$reportOutputDir = new PhingFile($this->reportDirectory);
$logMessage = "Report output directory doesn't exist, creating: " . $reportOutputDir->getAbsolutePath() . '.';
$this->log($logMessage);
$reportOutputDir->mkdirs();
}
if ($this->reportType !== 'cli') {
$this->reportFileName .= '.' . $this->reportType;
}
if (count($this->fileSets) > 0) {
foreach ($this->fileSets as $fileSet) {
$directoryScanner = $fileSet->getDirectoryScanner($this->project);
$files = $directoryScanner->getIncludedFiles();
$directory = $fileSet->getDir($this->project)->getPath();
foreach ($files as $file) {
if ($this->isFileSuffixSet($file)) {
$this->filesToCheck[] = $directory . DIRECTORY_SEPARATOR . $file;
}
}
}
$this->filesToCheck = array_unique($this->filesToCheck);
}
$this->runPhpLocCheck();
}
示例14: 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()) {
// 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) {
$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, $this->preservePermissions);
$count++;
} catch (IOException $ioe) {
$this->logError("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage());
}
}
}
}
示例15: main
/**
* Execute the input script with Velocity
*
* @throws BuildException
* BuildExceptions are thrown when required attributes are missing.
* Exceptions thrown by Velocity are rethrown as BuildExceptions.
*/
public function main()
{
// Make sure the template path is set.
if (empty($this->templatePath)) {
throw new BuildException("The template path needs to be defined!");
}
// Make sure the control template is set.
if ($this->controlTemplate === null) {
throw new BuildException("The control template needs to be defined!");
}
// Make sure the output directory is set.
if ($this->outputDirectory === null) {
throw new BuildException("The output directory needs to be defined!");
}
// Make sure there is an output file.
if ($this->outputFile === null) {
throw new BuildException("The output file needs to be defined!");
}
// Setup Smarty runtime.
// Smarty uses one object to store properties and to store
// the context for the template (unlike Velocity). We setup this object, calling it
// $this->context, and then initControlContext simply zeros out
// any assigned variables.
//
// Use the smarty backwards compatibility layer if existent.
if (class_exists('SmartyBC')) {
$this->context = new SmartyBC();
} else {
$this->context = new Smarty();
}
if ($this->compilePath !== null) {
$this->log("Using compilePath: " . $this->compilePath);
$this->context->compile_dir = $this->compilePath;
}
if ($this->configPath !== null) {
$this->log("Using configPath: " . $this->configPath);
$this->context->config_dir = $this->configPath;
}
if ($this->forceCompile !== null) {
$this->context->force_compile = $this->forceCompile;
}
if ($this->leftDelimiter !== null) {
$this->context->left_delimiter = $this->leftDelimiter;
}
if ($this->rightDelimiter !== null) {
$this->context->right_delimiter = $this->rightDelimiter;
}
if ($this->templatePath !== null) {
$this->log("Using templatePath: " . $this->templatePath);
$this->context->template_dir = $this->templatePath;
}
$smartyCompilePath = new PhingFile($this->context->compile_dir);
if (!$smartyCompilePath->exists()) {
$this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
if (!$smartyCompilePath->mkdirs()) {
throw new BuildException("Smarty needs a place to compile templates; specify a 'compilePath' or create " . $this->context->compile_dir);
}
}
// Make sure the output directory exists, if it doesn't
// then create it.
$file = new PhingFile($this->outputDirectory);
if (!$file->exists()) {
$this->log("Output directory does not exist, creating: " . $file->getAbsolutePath());
$file->mkdirs();
}
$path = $this->outputDirectory . DIRECTORY_SEPARATOR . $this->outputFile;
$this->log("Generating to file " . $path);
$writer = new FileWriter($path);
// The generator and the output path should
// be placed in the init context here and
// not in the generator class itself.
$c = $this->initControlContext();
// Set any variables that need to always
// be loaded
$this->populateInitialContext($c);
// Feed all the options into the initial
// control context so they are available
// in the control/worker templates.
if ($this->contextProperties !== null) {
foreach ($this->contextProperties->keys() as $property) {
$value = $this->contextProperties->getProperty($property);
// Special exception (from Texen)
// for properties ending in file.contents:
// in that case we dump the contents of the file
// as the "value" for the Property.
if (StringHelper::endsWith("file.contents", $property)) {
// pull in contents of file specified
$property = substr($property, 0, strpos($property, "file.contents") - 1);
// reset value, and then
// read in teh contents of the file into that var
$value = "";
$f = new PhingFile($this->project->resolveFile($value)->getCanonicalPath());
if ($f->exists()) {
//.........这里部分代码省略.........