本文整理汇总了PHP中Path::getRelative方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::getRelative方法的具体用法?PHP Path::getRelative怎么用?PHP Path::getRelative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::getRelative方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPathFields
protected static function getPathFields(Path $path)
{
$ret = array();
$ret['path'] = $path->getRelative();
$ret['path_hash'] = $path->getHash();
$ret['directory'] = $path->isDir();
$ret['size'] = $path->getSize();
$ret['created'] = date('Y-m-d H:i:s', $path->getCTime());
$ret['modified'] = date('Y-m-d H:i:s', $path->getMTime());
return $ret;
}
示例2: index
public static function index(Path $path, $levels = null, &$count = 0)
{
printf("Indexing: %s\n", $path->getRelative());
if (preg_match("/^\\.in\\./", $path->getFilename())) {
return;
}
try {
$record = $path->loadRecord();
// if this path does not exist, and we have a record then delete it
if (!$path->exists()) {
if ($record) {
$record->delete();
}
return;
}
if (!$record) {
// none exists, create it
$path->loadCreateRecord();
$count++;
} else {
// it exists, check if it needs updating
if ($record->checkUpdate($path)) {
$count++;
}
}
// index children
if ($levels > 0 || $levels === null) {
if ($levels !== null) {
$levels--;
}
if ($path->isDir()) {
$children = $path->getChildren();
foreach ($children as $child) {
self::index($child, $levels, $count);
}
}
}
} catch (Exception $e) {
print (string) $e;
Log::error($e, array('path' => $path->getRelative()));
}
}