本文整理汇总了PHP中Path::normalize方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::normalize方法的具体用法?PHP Path::normalize怎么用?PHP Path::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::normalize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOutputDir
/**
* Set temp path
* @param string $tempPath
*/
public function setOutputDir($tempPath)
{
$tempPath = Path::normalize($tempPath);
if (!is_dir($tempPath)) {
throw new FileNotFoundException("Temp path '{$tempPath}' does not exist.");
}
if (!is_writable($tempPath)) {
throw new InvalidArgumentException("Directory '{$tempPath}' is not writeable.");
}
$this->outputDir = $tempPath;
}
示例2: split
public static function split($path)
{
$path = Path::normalize($path);
$ret = array();
// we cut drive letter if os == windows and put it as first element
if ('\\' == self::SEPARATOR && preg_match('#^([a-z]:\\\\)#i', $path, $match)) {
$ret[] = substr($match[1], 0, 2);
$path = str_replace($match[1], '', $path);
}
return array_merge($ret, explode(self::SEPARATOR, $path));
}
示例3: cannonicalizePath
/**
* Make path absolute
* @param $path string
* @throws \WebLoader\FileNotFoundException
* @return string
*/
public function cannonicalizePath($path)
{
$rel = Path::normalize($this->root . "/" . $path);
if (file_exists($rel)) {
return $rel;
}
$abs = Path::normalize($path);
if (file_exists($abs)) {
return $abs;
}
throw new FileNotFoundException("File '{$path}' does not exist.");
}
示例4: rename
public function rename($newPath)
{
$newPathNormalized = Path::normalize($newPath);
$success = true;
if ($this->isExists()) {
$success = rename($this->getPhysicalPath(), Path::convertLogicalToPhysical($newPathNormalized));
}
if ($success) {
$this->originalPath = $newPath;
$this->path = $newPathNormalized;
$this->pathPhysical = null;
}
return $success;
}
示例5: nettoyer_chemin
public static function nettoyer_chemin($chemin, $est_un_motif = false)
{
// SÉCURITÉ : $chemin nettoyé
// * Ne contient pas '\0'
// * Ne contient pas '../'
// * Ne contient pas de double occurence de '/'
// * Ne se termine pas par '/'
// * Ne commence pas par '/'
// * Est découpé en segments
// * Chaque segment est nettoyé avec nettoyer_segment().
$chemin = preg_replace("/\\0/", '', $chemin);
// TODO : vérifier si c'est bien ça ! (supprime _toutes_ les occurences ???)
$chemin = Path::normalize($chemin);
$chemin = preg_replace("/^\\/*/", '', $chemin);
$chemin = preg_replace("/\\/*\$/", '', $chemin);
$segments = qw($chemin, '/');
if ($est_un_motif) {
$segments = array_map(array("self", "nettoyer_segment_motif"), $segments);
} else {
$segments = array_map(array("self", "nettoyer_segment"), $segments);
}
return $segments;
}
示例6: getRelative
/**
* Relative path to public temp directory
* @param null|string $fileName
* @return string
*/
public function getRelative($fileName = null)
{
return Path::normalize($this->relative . (empty($fileName) ? '' : '/' . $fileName));
}
示例7: testNormalize
/**
* @dataProvider getNormalizeData
*/
public function testNormalize($path, $expected)
{
$this->assertEquals($expected, Path::normalize($path));
}