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


PHP Dir::asDir方法代码示例

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


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

示例1: newTempFile

 /**
  *
  * Creates a new temporary file.
  *
  * @return \Mbcraft\Piol\File The new temporary file instance.
  *
  * @api
  */
 public static function newTempFile()
 {
     $full_path = tempnam(Dir::asDir(self::$tmp_file_path)->getFullPath(), "tmp_");
     return new File(File::toRelativePath($full_path));
 }
开发者ID:mbcraft,项目名称:piol,代码行数:13,代码来源:File.php

示例2: moveTo

 /**
  * 
  * Saves the uploaded file into the specified folder optionally overriding the filename used during upload.
  * The temporary upload file is deleted.
  * 
  * @param \Mbcraft\Piol\Dir|string $dir The Dir instance or string path of the folder in which save the uploaded file.
  * @param string $new_name the optional name to use for the file (overrides upload filename).
  * @return \Mbcraft\Piol\File a File instance pointing to the saved file, or null if an error occurred.
  *
  * @throws \Mbcraft\Piol\IOException if something goes wrong (eg. the provided filename is not valid).
  * 
  * @api
  */
 public function moveTo($dir, $new_name = null)
 {
     $final_dir = Dir::asDir($dir);
     FileSystemUtils::checkValidFilename($new_name);
     if ($new_name == null) {
         $real_filename = $this->getFullName();
     } else {
         $real_filename = $new_name;
     }
     $final_file = $final_dir->newFile($real_filename);
     return $this->saveAs($final_file);
 }
开发者ID:mbcraft,项目名称:piol,代码行数:25,代码来源:Upload.php

示例3: setPermissions

 /**
  * 
  * Sets the permissions on this directory using a 9 [rwx-] character string.
  * This operation is not guaranteed to succeed.
  * 
  * @param string $rwx_permissions The string permissions to set for this directory. 
  * @param boolean $recursive defaults to false, sets the permissions to all the child file system elements.
  * @return boolean true if the operation was succesfull, false otherwise.
  * 
  * @api
  */
 public function setPermissions($rwx_permissions, $recursive = false)
 {
     $result = $this->setPermissionsRwx($rwx_permissions);
     if ($recursive) {
         foreach ($this->listFolders() as $folder) {
             $rr = Dir::asDir($folder)->setPermissions($rwx_permissions, $recursive);
             $result &= $rr;
         }
         foreach ($this->listFiles() as $file) {
             $rr = File::asFile($file)->setPermissionsRwx($rwx_permissions);
             $result &= $rr;
         }
     }
     return $result;
 }
开发者ID:mbcraft,项目名称:piol,代码行数:26,代码来源:Dir.php

示例4: getPath

 /**
  * 
  * Returns the relative path of this element.
  * 
  * @param \Mbcraft\Piol\Dir|string $ancestor An optional ancestor Dir or string path for returning a shortened path.
  * @return string The string path
  * @throws \Mbcraft\Piol\IOException If the ancestor path is not a prefix of the relative path.
  * 
  * @api
  */
 public function getPath($ancestor = null)
 {
     if ($ancestor == null) {
         return $this->__path;
     } else {
         $relative_dir = Dir::asDir($ancestor);
         $path = $relative_dir->getPath();
         if (strpos($this->__path, $path) === 0) {
             return DS . substr($this->__path, strlen($path));
         } else {
             throw new IOException("Il percorso non comincia col percorso specificato : " . $this->__path . " non comincia con " . $path);
         }
     }
 }
开发者ID:mbcraft,项目名称:piol,代码行数:24,代码来源:__FileSystemElement.php


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