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


PHP Std::rm方法代码示例

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


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

示例1: checkCache

function checkCache()
{
    // Check if we hgave cache
    if (!file_exists($GLOBALS['tupac_directory'] . '/tupac_data')) {
        // If any of the main files is missing, regenerate cache
        Std::rm($GLOBALS['tupac_directory'] . '/tupac_data');
        Std::rm($GLOBALS['tupac_directory'] . '/tupac_filelist');
        sendMessage('generatingCache', array());
        // Gather information
        $GLOBALS['data'] = new PacmanData();
        $GLOBALS['data']->updateList();
    } else {
        // Read Cache
        $GLOBALS['data'] = unserialize(getFileContents($GLOBALS['tupac_directory'] . '/tupac_data'));
        if ($GLOBALS['data'] === false) {
            // Unserialized failed
            sendMessage('generatingCacheCorrupted', array());
            Std::rm($GLOBALS['tupac_directory'] . '/tupac_data');
            Std::rm($GLOBALS['tupac_directory'] . '/tupac_filelist');
            $GLOBALS['data'] = new PacmanData();
            $GLOBALS['data']->updateList();
        } else {
            switch ($GLOBALS['data']->verifyIntegrity()) {
                case 'cache_updated':
                    sendMessage('generatingCacheTupacUpdated', array());
                    Std::rm($GLOBALS['tupac_directory'] . '/tupac_data');
                    Std::rm($GLOBALS['tupac_directory'] . '/tupac_filelist');
                    $GLOBALS['data'] = new PacmanData();
                    $GLOBALS['data']->updateList();
                    break;
                case 'database_outdated':
                    //sendMessage('generatingCacheDatabaseUpdated',array());
                    $anyChanges = false;
                    // Get currently available repos
                    $available_repos = array();
                    $dh = getRepoDirList();
                    foreach ($dh as $repo) {
                        if (!substr($repo, 0, 1) == '.' && is_dir(getRepoDir($repo))) {
                            $available_repos[$repo] = false;
                        }
                    }
                    // The database needs to be updated
                    $mustRecheckLocal = false;
                    $repo_list = $GLOBALS['data']->repo_list;
                    foreach ($repo_list as $repo => $repoData) {
                        unset($available_repos[$repo]);
                        if ($repo == 'local' && $GLOBALS['data']->verification[$repo] != PacmanData::verifyRepo($repo)) {
                            // We check local separately, since it is not a repo.
                            sendMessage('repoIsUpdated', array('%r' => $repo));
                            $anyChanges = true;
                            $installed = true;
                            $available_packages = array();
                            // get current packages
                            $dh = opendir(getRepoDir($repo));
                            while (FALSE !== ($package = readdir($dh))) {
                                if (substr($package, 0, 1) != '.' && is_dir(getRepoDir($repo) . $package)) {
                                    $packageName = preg_replace('/\\-[0-9a-z\\._A-Z]*\\-[0-9a-z\\._A-Z]*$/', '', $package);
                                    $available_packages[$packageName] = $package;
                                }
                            }
                            closedir($dh);
                            $installed_packages = $GLOBALS['data']->installed_packages;
                            // Walk packages of the current repo
                            foreach ($installed_packages as $packageName => $packageData) {
                                if (!$available_packages[$packageName]) {
                                    // The package is not installed anymore
                                    sendMessage('removePackage', array('%p' => $packageName));
                                    unset($repo_list['local'][$packageName]);
                                    foreach ($repo_list as $tmpRepo => $tmpRepoData) {
                                        if ($tmpRepoData[$packageName]) {
                                            $repo_list[$tmpRepo][$packageName]['installed'] = 'false';
                                        }
                                    }
                                    unset($installed_packages[$packageName]);
                                } elseif ($packageData['dir'] != $available_packages[$packageName]) {
                                    // Package updated. Since it is the list of installed packages, set its version to installed version
                                    sendMessage('updatePackage', array('%p' => $packageName));
                                    $installed_packages[$packageName] = PacmanData::getPackageData($repo, $available_packages[$packageName], 'true');
                                    $installed_info = $installed_packages[$packageName]['version'];
                                    $installed_packages[$packageName]['installed'] = $installed_info;
                                    foreach ($repo_list as $tmpRepo => $tmpRepoData) {
                                        if ($tmpRepoData[$packageName]) {
                                            $repo_list[$tmpRepo][$packageName]['installed'] = $installed_info;
                                            // in local installed version equals to avaiable version
                                            if ($repo == 'local') {
                                                $repo_list[$tmpRepo][$packageName]['version'] = $installed_info;
                                            }
                                        }
                                    }
                                }
                                unset($available_packages[$packageName]);
                            }
                            // Add new packages. This is, packages that are listed in the repo directory but that aren't marked as installed.
                            foreach ($available_packages as $packageName => $package) {
                                if ($package) {
                                    $packageFound = false;
                                    sendMessage('addPackage', array('%p' => $packageName));
                                    $installed_packages[$packageName] = PacmanData::getPackageData($repo, $available_packages[$packageName], 'true');
                                    $installed_info = $installed_packages[$packageName]['version'];
                                    $installed_packages[$packageName]['installed'] = $installed_info;
//.........这里部分代码省略.........
开发者ID:Kett,项目名称:tupac,代码行数:101,代码来源:tupac.inc.php


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