本文整理汇总了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));
}
示例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);
}
示例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;
}
示例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);
}
}
}