本文整理汇总了PHP中Cake\Filesystem\File::folder方法的典型用法代码示例。如果您正苦于以下问题:PHP File::folder方法的具体用法?PHP File::folder怎么用?PHP File::folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\File
的用法示例。
在下文中一共展示了File::folder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _unzip
/**
* Extracts the current ZIP package.
*
* @param string $file Full path to the ZIP package
* @return bool True on success
*/
protected function _unzip($file)
{
include_once Plugin::classPath('Installer') . 'Lib/pclzip.lib.php';
$File = new File($file);
$to = normalizePath($File->folder()->pwd() . '/' . $File->name() . '_unzip/');
if (is_readable($to)) {
$folder = new Folder($to);
$folder->delete();
} else {
$folder = new Folder($to, true);
}
$PclZip = new \PclZip($file);
$PclZip->delete(PCLZIP_OPT_BY_EREG, '/__MACOSX/');
$PclZip->delete(PCLZIP_OPT_BY_EREG, '/\\.DS_Store$/');
if ($PclZip->extract(PCLZIP_OPT_PATH, $to)) {
list($directories, $files) = $folder->read(false, false, true);
if (count($directories) === 1 && empty($files)) {
$container = new Folder($directories[0]);
$container->move(['to' => $to]);
}
$this->_workingDir = $to;
return true;
}
$this->err(__d('installer', 'Unzip error: {0}', [$PclZip->errorInfo(true)]));
return false;
}
示例2: _removeFile
/**
* _removeFile
*
* @param string $file Path of the file
* @return bool
*/
protected function _removeFile($file)
{
$_file = new File($file);
if ($_file->exists()) {
$_file->delete();
$folder = $_file->folder();
if (count($folder->find()) === 0) {
$folder->delete();
}
return true;
}
return false;
}