本文整理汇总了PHP中eZClusterFileHandler::cleanupEmptyDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP eZClusterFileHandler::cleanupEmptyDirectories方法的具体用法?PHP eZClusterFileHandler::cleanupEmptyDirectories怎么用?PHP eZClusterFileHandler::cleanupEmptyDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZClusterFileHandler
的用法示例。
在下文中一共展示了eZClusterFileHandler::cleanupEmptyDirectories方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purge
function purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)
{
$file = $this->filePath;
if ($max === false) {
$max = 100;
}
$count = 0;
$list = array();
if (is_file($file)) {
$list = array($file);
} else {
$globResult = glob($file . "/*");
if (is_array($globResult)) {
$list = $globResult;
}
}
do {
if ($count % $max == 0 && $microsleep) {
usleep($microsleep);
}
// Sleep a bit to make the filesystem happier
$count = 0;
$file = array_shift($list);
if (is_file($file)) {
$mtime = @filemtime($file);
if ($expiry === false || $mtime < $expiry) {
@unlink($file);
eZClusterFileHandler::cleanupEmptyDirectories($file);
}
++$count;
} else {
if (is_dir($file)) {
$globResult = glob($file . "/*");
if (is_array($globResult)) {
$list = array_merge($globResult, $list);
}
}
}
if ($printCallback) {
call_user_func_array($printCallback, array($file, 1));
}
} while (count($list) > 0);
}
示例2: renameOnDFS
/**
* Renamed DFS file $oldPath to DFS file $newPath
*
* @param string $oldPath
* @param string $newPath
* @return bool
*/
public function renameOnDFS($oldPath, $newPath)
{
$this->accumulatorStart();
$oldPath = $this->makeDFSPath($oldPath);
$newPath = $this->makeDFSPath($newPath);
$ret = eZFile::rename($oldPath, $newPath, true);
if ($ret) {
eZClusterFileHandler::cleanupEmptyDirectories($oldPath);
}
$this->accumulatorStop();
return $ret;
}
示例3: purge
/**
* Purge local and remote file data for current file.
*/
function purge( $printCallback = false, $microsleep = false, $max = false, $expiry = false )
{
$file = $this->filePath;
if ( $max === false )
$max = 100;
$count = 0;
if ( is_file( $file ) )
$list = array( $file );
else
$list = glob( $file . "/*" );
do
{
if ( ( $count % $max ) == 0 && $microsleep )
usleep( $microsleep ); // Sleep a bit to make the filesystem happier
$count = 0;
$file = array_shift( $list );
if ( is_file( $file ) )
{
$mtime = @filemtime( $file );
if ( $expiry === false ||
$mtime < $expiry ) // remove it if it is too old
{
@unlink( $file );
eZClusterFileHandler::cleanupEmptyDirectories( $file );
}
++$count;
}
else if ( is_dir( $file ) )
{
$list = array_merge( $list, glob( $file . "/*" ) );
}
if ( $printCallback )
call_user_func_array( $printCallback,
array( $file, 1 ) );
} while ( count( $list ) > 0 );
}
示例4: purge
/**
* Purges local and remote file data for current file path.
*
* Can be given a file or a folder. In order to clear a folder, do NOT add
* a trailing / at the end of the file's path: path/to/file instead of
* path/to/file/.
*
* By default, only expired files will be removed (ezdfsfile.expired = 1).
* If you specify an $expiry time, it will replace the expired test and
* only purge files older than the given expiry timestamp.
*
* @param callback $printCallback
* Callback called after each delete iteration (@see $max) to print
* out a report of the deleted files. This callback expects two
* parameters, $file (delete pattern used to perform deletion) and
* $count (number of deleted items)
* @param int $microsleep
* Wait interval before each purge batch of $max items
* @param int $max
* Maximum number of items to delete in one batch (default: 100)
* @param int $expiry
* If specificed, only files older than this date will be purged
* @return void
*/
function purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)
{
eZDebugSetting::writeDebug('kernel-clustering', "dfs::purge( '{$this->filePath}' )");
$file = $this->filePath;
if ($max === false) {
$max = 100;
}
$count = 0;
/**
* The loop starts without knowing how many files are to be deleted.
* When _purgeByLike is called, it returns the number of affected rows.
* If rows were affected, _purgeByLike will be called again
*/
do {
// @todo this won't work on windows, make a wrapper that uses
// either usleep or sleep depending on the OS
if ($count > 0 && $microsleep) {
usleep($microsleep);
// Sleep a bit to make the database happier
}
$count = self::$dbbackend->_purgeByLike($file . "/%", true, $max, $expiry, 'purge');
self::$dbbackend->_purge($file, true, $expiry, 'purge');
if ($printCallback) {
call_user_func_array($printCallback, array($file, $count));
}
// @todo Compare $count to $max. If $count < $max, no more files are to
// be purged, and we can exit the loop
} while ($count > 0);
// Remove local copies
if (is_file($file)) {
@unlink($file);
} elseif (is_dir($file)) {
eZDir::recursiveDelete($file);
}
eZClusterFileHandler::cleanupEmptyDirectories($file);
}
示例5: purge
function purge( $printCallback = false, $microsleep = false, $max = false, $expiry = false )
{
$file = $this->filePath;
if ( $max === false )
$max = 100;
$count = 0;
do
{
if ( $count > 0 && $microsleep )
usleep( $microsleep ); // Sleep a bit to make the database happier
$count = self::$dbbackend->_purgeByLike( $file . "/%", true, $max, $expiry, 'purge' );
self::$dbbackend->_purge( $file, true, $expiry, 'purge' );
if ( $printCallback )
call_user_func_array( $printCallback,
array( $file, $count ) );
} while ( $count > 0 );
// Remove local copy
if ( is_file( $file ) )
{
@unlink( $file );
}
else if ( is_dir( $file ) )
{
eZDir::recursiveDelete( $file );
}
eZClusterFileHandler::cleanupEmptyDirectories( $file );
}