当前位置: 首页>>代码示例>>PHP>>正文


PHP Safe::rmdir方法代码示例

本文整理汇总了PHP中Safe::rmdir方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::rmdir方法的具体用法?PHP Safe::rmdir怎么用?PHP Safe::rmdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Safe的用法示例。


在下文中一共展示了Safe::rmdir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete_staging

/**
 * delete staging files
 *
 * @param string the directory to start with
 * @see scripts/update.php
 */
function delete_staging($path)
{
    global $context;
    $path_translated = str_replace('//', '/', $context['path_to_root'] . '/scripts/staging' . $path);
    if ($handle = Safe::opendir($path_translated)) {
        while (($node = Safe::readdir($handle)) !== FALSE) {
            if ($node == '.' || $node == '..') {
                continue;
            }
            // make a real name
            $target = str_replace('//', '/', $path . '/' . $node);
            $target_translated = str_replace('//', '/', $path_translated . '/' . $node);
            // delete sub directory content
            if (is_dir($target_translated)) {
                delete_staging($target);
                Safe::rmdir($target_translated);
                // delete all files
            } else {
                $context['text'] .= sprintf(i18n::s('Deleting %s'), '/scripts/staging' . $target) . BR . "\n";
                Safe::unlink($target_translated);
                global $deleted_nodes;
                $deleted_nodes++;
            }
            // ensure we have enough time
            Safe::set_time_limit(30);
        }
        Safe::closedir($handle);
    }
}
开发者ID:rair,项目名称:yacs,代码行数:35,代码来源:purge.php

示例2: delete_all

/**
 * delete a directory and all of its content
 *
 * @param string the directory to delete
 */
function delete_all($path)
{
    global $context;
    $path_translated = str_replace('//', '/', $context['path_to_root'] . '/' . $path);
    if ($handle = Safe::opendir($path_translated)) {
        while (($node = Safe::readdir($handle)) !== FALSE) {
            if ($node[0] == '.') {
                continue;
            }
            // make a real name
            $target = str_replace('//', '/', $path . '/' . $node);
            $target_translated = str_replace('//', '/', $path_translated . '/' . $node);
            // delete a sub directory
            if (is_dir($target_translated)) {
                delete_all($path . '/' . $node);
                Safe::rmdir($target_translated);
                // delete the node
            } else {
                Safe::unlink($target_translated);
            }
            // statistics
            global $deleted_nodes;
            $deleted_nodes++;
        }
        Safe::closedir($handle);
    }
}
开发者ID:rair,项目名称:yacs,代码行数:32,代码来源:stage.php

示例3: delete

 /**
  * delete one file in the database and in the file system
  *
  * @param int the id of the file to delete
  * @return boolean TRUE on success, FALSE otherwise
  */
 public static function delete($id)
 {
     global $context;
     // load the row
     $item = Files::get($id);
     if (!$item['id']) {
         Logger::error(i18n::s('No item has the provided id.'));
         return FALSE;
     }
     // actual deletion of the file
     $file_path = $context['path_to_root'] . Files::get_path($item['anchor']);
     Safe::unlink($file_path . '/' . $item['file_name']);
     Safe::unlink($file_path . '/thumbs/' . $item['file_name']);
     Safe::rmdir($file_path . '/thumbs');
     Safe::rmdir($file_path);
     Safe::rmdir(dirname($file_path));
     // delete related items
     Anchors::delete_related_to('file:' . $id);
     // delete the record in the database
     $query = "DELETE FROM " . SQL::table_name('files') . " WHERE id = " . SQL::escape($item['id']);
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // job done
     return TRUE;
 }
开发者ID:rair,项目名称:yacs,代码行数:32,代码来源:files.php


注:本文中的Safe::rmdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。