当前位置: 首页>>代码示例>>PHP>>正文


PHP Folder::addPathElement方法代码示例

本文整理汇总了PHP中Folder::addPathElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::addPathElement方法的具体用法?PHP Folder::addPathElement怎么用?PHP Folder::addPathElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Folder的用法示例。


在下文中一共展示了Folder::addPathElement方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copySourceToWorkingDir

 /**
  * Copy over source file to working dir
  * @param $sourceFile
  * @param $processingBookType
  * @param $sourceFileCount
  * @throws Exception
  */
 protected function copySourceToWorkingDir($sourceFile)
 {
     static $importPageNumber;
     // Check if this is an image
     if ($this->isValidSourceFile($sourceFile)) {
         $importPageNumber = (int) $importPageNumber + 1;
         // Get source file
         $source = Folder::addPathElement(Configure::read('Chaucer.sourceDir'), $sourceFile['filename']);
         // Set target file
         // In case of images increment filename with number padding
         $assetNumPad = str_pad($importPageNumber, 4, '0', STR_PAD_LEFT);
         // Assemble asset name
         $assetFilename = 'image' . $assetNumPad . '.';
         $assetFilename .= MediaManager::isConvertableImage($source) ? 'png' : $sourceFile['ext'];
         // Set target
         $target = Folder::addPathElement($this->workingDir, $assetFilename);
         // Log the message
         CakeLog::debug('[ImageProcessor::getBookSourceFiles] ' . 'Preparing to copy remote file on instance ' . Configure::read('Chaucer.instanceName') . ': ' . $source . ' to ' . $target);
         // Get the source file from remote
         $this->FileManager->copy($source, $target);
         if (file_exists($target)) {
             $this->sourceFiles[] = $target;
         } else {
             throw new Exception('[ImageProcessor::getBookSourceFiles] ' . 'Unable to copy book source file.');
         }
         return true;
     }
     return false;
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:36,代码来源:ImageProcessor.php

示例2: testBasic

 /**
  * testBasic method
  *
  * @access public
  * @return void
  */
 function testBasic()
 {
     $path = dirname(__FILE__);
     $Folder =& new Folder($path);
     $result = $Folder->pwd();
     $this->assertEqual($result, $path);
     $result = Folder::addPathElement($path, 'test');
     $expected = $path . DS . 'test';
     $this->assertEqual($result, $expected);
     $result = $Folder->cd(ROOT);
     $expected = ROOT;
     $this->assertEqual($result, $expected);
     $result = $Folder->cd(ROOT . DS . 'non-existent');
     $this->assertFalse($result);
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:21,代码来源:folder.test.php

示例3: initWorkingDir

 /**
  * Initialize the working directory and ensure it exists
  * @return  string  Path to working directory
  */
 public function initWorkingDir()
 {
     // Check if working directory is already initialized
     if (is_dir($this->workingDir)) {
         return $this->workingDir;
     }
     // Get temp target directory
     $tmpDir = Configure::read('Chaucer.instanceName') . '/' . $this->bookId;
     $targetDir = Folder::addPathElement($this->FileManager->getTmpPath(), $tmpDir);
     // Create and return dir
     if (!$this->FileManager->createDir($targetDir)) {
         throw new Exception('Unable to create working directory: ' . $targetDir);
     }
     CakeLog::debug('[CommonProcessor::initWorkingDir] working dir: ' . $targetDir);
     return $targetDir;
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:20,代码来源:CommonProcessor.php

示例4: realpath

 /**
  * Get the real path (taking ".." and such into account)
  *
  * @param string $path Path to resolve
  * @return string The resolved path
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
  */
 public function realpath($path)
 {
     $path = str_replace('/', DS, trim($path));
     if (strpos($path, '..') === false) {
         if (!Folder::isAbsolute($path)) {
             $path = Folder::addPathElement($this->path, $path);
         }
         return $path;
     }
     $parts = explode(DS, $path);
     $newparts = array();
     $newpath = '';
     if ($path[0] === DS) {
         $newpath = DS;
     }
     while (($part = array_shift($parts)) !== NULL) {
         if ($part === '.' || $part === '') {
             continue;
         }
         if ($part === '..') {
             if (!empty($newparts)) {
                 array_pop($newparts);
                 continue;
             } else {
                 return false;
             }
         }
         $newparts[] = $part;
     }
     $newpath .= implode(DS, $newparts);
     return Folder::slashTerm($newpath);
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:39,代码来源:Folder.php

示例5: testAddPathElement

 /**
  * test Adding path elements to a path
  *
  * @return void
  */
 public function testAddPathElement()
 {
     $expected = DS . 'some' . DS . 'dir' . DS . 'another_path';
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path');
     $this->assertEquals($expected, $result);
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path');
     $this->assertEquals($expected, $result);
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir', array('another_path'));
     $this->assertEquals($expected, $result);
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, array('another_path'));
     $this->assertEquals($expected, $result);
     $expected = DS . 'some' . DS . 'dir' . DS . 'another_path' . DS . 'and' . DS . 'another';
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir', array('another_path', 'and', 'another'));
     $this->assertEquals($expected, $result);
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:20,代码来源:FolderTest.php

示例6: testAddPathElement

 /**
  * test Adding path elements to a path
  *
  * @return void
  */
 public function testAddPathElement()
 {
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path');
     $this->assertEquals(DS . 'some' . DS . 'dir' . DS . 'another_path', $result);
     $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path');
     $this->assertEquals(DS . 'some' . DS . 'dir' . DS . 'another_path', $result);
 }
开发者ID:Juan09130424,项目名称:CakePHP---Bootstrap-template,代码行数:12,代码来源:FolderTest.php

示例7: array

 /**
  * Recursive directory copy.
  *
  * @param string $fromDir
  * @param string $toDir
  * @param octal $chmod
  * @param boolean	 $verbose
  * @return Success.
  */
 function __copydirr($fromDir, $toDir, $chmod = 0755, $verbose = false)
 {
     $errors = array();
     $messages = array();
     uses('folder');
     $folder = new Folder($toDir, true, 0755);
     if (!is_writable($toDir)) {
         $errors[] = 'target ' . $toDir . ' is not writable';
     }
     if (!is_dir($fromDir)) {
         $errors[] = 'source ' . $fromDir . ' is not a directory';
     }
     if (!empty($errors)) {
         if ($verbose) {
             foreach ($errors as $err) {
                 $this->stdout('Error: ' . $err);
             }
         }
         return false;
     }
     $exceptions = array('.', '..', '.svn');
     $handle = opendir($fromDir);
     while (false !== ($item = readdir($handle))) {
         if (!in_array($item, $exceptions)) {
             $from = $folder->addPathElement($fromDir, $item);
             $to = $folder->addPathElement($toDir, $item);
             if (is_file($from)) {
                 if (@copy($from, $to)) {
                     chmod($to, $chmod);
                     touch($to, filemtime($from));
                     $messages[] = 'File copied from ' . $from . ' to ' . $to;
                 } else {
                     $errors[] = 'cannot copy file from ' . $from . ' to ' . $to;
                 }
             }
             if (is_dir($from)) {
                 if (@mkdir($to)) {
                     chmod($to, $chmod);
                     $messages[] = 'Directory created: ' . $to;
                 } else {
                     $errors[] = 'cannot create directory ' . $to;
                 }
                 $this->__copydirr($from, $to, $chmod, $verbose);
             }
         }
     }
     closedir($handle);
     if ($verbose) {
         foreach ($errors as $err) {
             $this->stdout('Error: ' . $err);
         }
         foreach ($messages as $msg) {
             $this->stdout($msg);
         }
     }
     return true;
 }
开发者ID:carriercomm,项目名称:pastebin-5,代码行数:66,代码来源:bake.php

示例8: copy

 /**
  *	Copy
  *	@param array $options
  *	@return BOOL
  */
 public function copy($options = [])
 {
     if (!$this->path) {
         return false;
     }
     $to = null;
     if (is_string($options)) {
         $to = $options;
         $options = array();
     }
     $options = array_merge(array('to' => $to, 'from' => $this->path, 'mode' => $this->folderChmod, 'skip' => array()), $options);
     $fromDir = $options['from'];
     $toDir = $options['to'];
     $mode = $options['mode'];
     if (!$this->cd($fromDir)) {
         $this->_errors[] = sprintf('%s not found', $fromDir);
         return false;
     }
     if (!is_dir($toDir)) {
         $this->makeDir($toDir);
     }
     if (!is_writable($toDir)) {
         $this->_errors[] = sprintf('%s not writable', $toDir);
         return false;
     }
     $exceptions = array_merge(array('.', '..', '.svn'), $options['skip']);
     if ($handle = @opendir($fromDir)) {
         while (false !== ($item = readdir($handle))) {
             if (!in_array($item, $exceptions)) {
                 $from = Folder::addPathElement($fromDir, $item);
                 $to = Folder::addPathElement($toDir, $item);
                 if (is_file($from)) {
                     if (copy($from, $to)) {
                         chmod($to, intval($mode, 8));
                         touch($to, filemtime($from));
                         $this->_messages[] = sprintf('%s copied to %s', $from, $to);
                     } else {
                         $this->_errors[] = sprintf('%s NOT copied to %s', $from, $to);
                     }
                 }
                 if (is_dir($from) && !file_exists($to)) {
                     $old = umask(0);
                     if (mkdir($to, $mode)) {
                         umask($old);
                         $old = umask(0);
                         chmod($to, $mode);
                         umask($old);
                         $this->_messages[] = sprintf('%s created', $to);
                         $options = array_merge($options, array('to' => $to, 'from' => $from));
                         $this->copy($options);
                     } else {
                         $this->_errors[] = sprintf('%s not created', $to);
                     }
                 }
             }
         }
         closedir($handle);
     } else {
         return false;
     }
     if (!empty($this->_errors)) {
         return false;
     }
     return true;
 }
开发者ID:touchbase,项目名称:touchbase,代码行数:70,代码来源:Folder.php

示例9: copy

 /**
  * Recursive directory copy.
  *
  * ### Options
  *
  * - `to` The directory to copy to.
  * - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd().
  * - `mode` The mode to copy the files/directories with.
  * - `skip` Files/directories to skip.
  * - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP
  *
  * @param array|string $options Either an array of options (see above) or a string of the destination directory.
  *
  * @return boolean Success
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
  */
 public function copy($options)
 {
     if (!$this->pwd()) {
         return false;
     }
     $to = null;
     if (is_string($options)) {
         $to = $options;
         $options = array();
     }
     $options = array_merge(array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array(), 'scheme' => Folder::MERGE), $options);
     $fromDir = $options['from'];
     $toDir = $options['to'];
     $mode = $options['mode'];
     if (!$this->cd($fromDir)) {
         $this->_errors[] = __d('cake_dev', '%s not found', $fromDir);
         return false;
     }
     if (!is_dir($toDir)) {
         $this->create($toDir, $mode);
     }
     if (!is_writable($toDir)) {
         $this->_errors[] = __d('cake_dev', '%s not writable', $toDir);
         return false;
     }
     $exceptions = array_merge(array('.', '..', '.svn'), $options['skip']);
     //@codingStandardsIgnoreStart
     if ($handle = @opendir($fromDir)) {
         //@codingStandardsIgnoreEnd
         while (($item = readdir($handle)) !== false) {
             $to = Folder::addPathElement($toDir, $item);
             if (($options['scheme'] != Folder::SKIP || !is_dir($to)) && !in_array($item, $exceptions)) {
                 $from = Folder::addPathElement($fromDir, $item);
                 if (is_file($from)) {
                     if (copy($from, $to)) {
                         chmod($to, intval($mode, 8));
                         touch($to, filemtime($from));
                         $this->_messages[] = __d('cake_dev', '%s copied to %s', $from, $to);
                     } else {
                         $this->_errors[] = __d('cake_dev', '%s NOT copied to %s', $from, $to);
                     }
                 }
                 if (is_dir($from) && file_exists($to) && $options['scheme'] == Folder::OVERWRITE) {
                     $this->delete($to);
                 }
                 if (is_dir($from) && !file_exists($to)) {
                     $old = umask(0);
                     if (mkdir($to, $mode)) {
                         umask($old);
                         $old = umask(0);
                         chmod($to, $mode);
                         umask($old);
                         $this->_messages[] = __d('cake_dev', '%s created', $to);
                         $options = array_merge($options, array('to' => $to, 'from' => $from));
                         $this->copy($options);
                     } else {
                         $this->_errors[] = __d('cake_dev', '%s not created', $to);
                     }
                 } elseif (is_dir($from) && $options['scheme'] == Folder::MERGE) {
                     $options = array_merge($options, array('to' => $to, 'from' => $from));
                     $this->copy($options);
                 }
             }
         }
         closedir($handle);
     } else {
         return false;
     }
     if (!empty($this->_errors)) {
         return false;
     }
     return true;
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:89,代码来源:Folder.php

示例10: getFullFilePath

 protected function getFullFilePath()
 {
     $path = $this->FileManager->getRemoteRootDir();
     $path = Folder::addPathElement($path, 'Source');
     return $path;
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:6,代码来源:IdmlResourceManager.php

示例11: setCoverImage

 /**
  * Adds a page to the beginning of the book to display the cover page. uses the book_cover field from the books
  * table to determine the image file
  *
  * @return string path to cover image. Relative in S3, absolute locally
  */
 public function setCoverImage()
 {
     $book = $this->bookData->getBookItem();
     $coverSource = trim($book['ChChaucerBook']['book_cover']);
     $path = '';
     if (strlen($coverSource) > 0) {
         CakeLog::debug('[ImportProcessor::addCoverPageImage] Book ' . $book['ChChaucerBook']['book_id'] . ' has cover image: ' . $coverSource);
         $path = $this->epub->addCoverImage(Folder::addPathElement(Configure::read('Chaucer.sourceDir'), $coverSource));
         $book['ChChaucerBook']['book_cover'] = $coverSource;
         $this->bookData->saveBook($book);
         return $this->epub->epubRoot() . $path;
     }
     return '';
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:20,代码来源:ImportProcessor.php

示例12: createImageAssets

 /**
  * Create image assets.
  */
 private function createImageAssets()
 {
     // Get image directory
     $imageDir = Folder::addPathElement($this->workingDir, 'images');
     if (is_dir($imageDir)) {
         // Get all image files
         $imageFiles = $this->FileManager->getAllFiles($imageDir);
         // Check if there are any images
         if (count($imageFiles) > 0) {
             // Adjust progress
             $this->progress->adjustMaxSteps(count($imageFiles), TRUE);
             // Loop through image files
             foreach ($imageFiles as $imagePath) {
                 // Get file image name
                 $imagePathInfo = pathinfo($imagePath);
                 $imageFilename = $imagePathInfo['basename'];
                 // Check if image exists
                 if (file_exists($imagePath)) {
                     // Path to unlink
                     $imagePathUnlink = $imagePath;
                     // Import image files
                     $this->addImageAssetToBook($imagePath, 'images/');
                     // Remove image files
                     unlink($imagePathUnlink);
                 } else {
                     CakeLog::warning("[WordProcessor::importImages] File {$imageFilename} not found");
                 }
                 // Update step
                 $this->progress->incrementStep();
             }
         }
     }
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:36,代码来源:WordProcessor.php

示例13: getBookCSS

 /**
  * Get Book CSS by reading css/template.css and stripping the font-face rules
  * @return  string  CSS content
  */
 protected function getBookCSS()
 {
     // Get template CSS
     $file = Folder::addPathElement($this->workingDir, "Styles/template.css");
     if (file_exists($file)) {
         // Strip @font-face
         $css = file_get_contents($file);
         while (strpos($css, '@font-face') !== false) {
             $start = strpos($css, '@font-face');
             $end = strpos($css, "}", $start);
             $pre = substr($css, 0, $start - 1);
             $post = substr($css, $end + 1);
             $css = $pre . $post;
         }
         // Return CSS
         return $css;
     }
     // Return empty string if there is no file
     return "";
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:24,代码来源:PdfProcessor.php


注:本文中的Folder::addPathElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。