本文整理汇总了PHP中Path::dirContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::dirContent方法的具体用法?PHP Path::dirContent怎么用?PHP Path::dirContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::dirContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public function generate()
{
set_time_limit(600);
$this->autoRender = false;
App::uses('Path', 'Core.Vendor');
Configure::write('Config.language', 'rus');
$msgFile = '../Locale/' . Configure::read('Config.language') . '/LC_MESSAGES/default.';
$this->msgFile = $msgFile . 'po';
file_put_contents($msgFile . 'bak', file_get_contents($msgFile . 'po'), false);
Path::process(Path::dirContent('../'), array($this, '_process'), true);
echo $this->count . ' label(s) processed';
}
示例2: process
public static function process($aPath, $callbackProcessFn, $recursive = false, $aParams = array())
{
if (isset($aPath['files'])) {
foreach ($aPath['files'] as $fname) {
call_user_func($callbackProcessFn, $fname, $aPath['path'], $aParams);
}
}
if ($recursive && isset($aPath['folders'])) {
foreach ($aPath['folders'] as $folder) {
Path::process(Path::dirContent($aPath['path'] . $folder . '/'), $callbackProcessFn, true, $aParams);
}
}
}
示例3: beforeDelete
/**
* Removes actual media-files before delete a record
*
* @param bool $cascade
* @return bool
*/
public function beforeDelete($cascade = true)
{
App::uses('Path', 'Core.Vendor');
$media = $this->findById($this->id);
if ($media) {
$path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $this->id);
if (file_exists($path)) {
// remove all files in folder
$aPath = Path::dirContent($path);
if (isset($aPath['files']) && $aPath['files']) {
foreach ($aPath['files'] as $file) {
unlink($aPath['path'] . $file);
}
}
rmdir($path);
}
}
return true;
}
示例4: cleanCache
/**
* Removes all temp cached images
*
* @param int $id
*/
public function cleanCache($id)
{
App::uses('Path', 'Core.Vendor');
$media = $this->findById($id);
if (Hash::get($media, $this->alias . '.media_type') == 'image') {
$path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $id);
if (file_exists($path)) {
// remove all files in folder
$aPath = Path::dirContent($path);
if (isset($aPath['files']) && $aPath['files']) {
foreach ($aPath['files'] as $file) {
if ($file != $media[$this->alias]['file'] . $media[$this->alias]['ext'] && $file != 'thumb.png') {
unlink($aPath['path'] . $file);
}
}
}
}
}
}
示例5: beforeDelete
/**
* Removes actual media-files before delete a record
*
* @param bool $cascade
* @return bool
*/
public function beforeDelete($cascade = true)
{
App::uses('Path', 'Core.Vendor');
$media = $this->findById($this->id);
if (!empty($media['Media']['orig_fsize'])) {
$file_size = $media['Media']['orig_fsize'];
if ($file_size > 0) {
App::uses('CakeSession', 'Model/Datasource');
$user_id = CakeSession::read('Auth.User.id');
$this->updateStorageData($user_id, 'Cloud', $file_size, $operation = 'subtract');
}
}
if ($media) {
$path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $this->id);
if (file_exists($path)) {
// remove all files in folder
$aPath = Path::dirContent($path);
if (isset($aPath['files']) && $aPath['files']) {
foreach ($aPath['files'] as $file) {
unlink($aPath['path'] . $file);
}
}
rmdir($path);
}
}
return true;
}