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


PHP CFile::exists方法代码示例

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


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

示例1: maybeUpdateThirdParty

 /**
  * @ignore
  */
 public static function maybeUpdateThirdParty()
 {
     if (!self::isInCliMode()) {
         // This method can be run in CLI mode only.
         assert('false', vs(isset($this), get_defined_vars()));
         return false;
     }
     $updates = CConfiguration::option("updates");
     $updatesAreEnabled = $updates["enable"];
     if ($updatesAreEnabled) {
         $minTimeBetweenDoUpdatesDays = $updates["minTimeBetweenDoUpdatesDays"];
         $components = $updates["components"];
         assert('is_int($minTimeBetweenDoUpdatesDays)', vs(isset($this), get_defined_vars()));
         // Logging.
         $logging = $updates["logging"];
         $loggingIsEnabled = $logging["enable"];
         $logFp = $logging["logFilePath"];
         if ($loggingIsEnabled) {
             assert('!CString::isEmpty($logFp)', vs(isset($this), get_defined_vars()));
             $logFp = CFilePath::frameworkPath($logFp);
             CShell::setLogging($logFp);
         }
         // Mailing.
         $mailing = $updates["mailing"];
         $mailingIsEnabled = $mailing["enable"];
         if ($mailingIsEnabled) {
             $adminMail = CConfiguration::option("admin.mail");
             $to = $adminMail["to"];
             $from = $adminMail["from"];
             $transport = $adminMail["transport"];
             assert('!CString::isEmpty($to) && !CString::isEmpty($from) && !CString::isEmpty($transport)', vs(isset($this), get_defined_vars()));
             $mail;
             if (CString::equalsCi($transport, "smtp")) {
                 $smtpOutgoingServer = $adminMail["smtpOutgoingServer"];
                 $smtpUsername = $adminMail["smtpUsername"];
                 $smtpPassword = $adminMail["smtpPassword"];
                 assert('!CString::isEmpty($smtpOutgoingServer) && !CString::isEmpty($smtpUsername) && ' . '!CString::isEmpty($smtpPassword)', vs(isset($this), get_defined_vars()));
                 $mail = CMail::makeSmtp($smtpOutgoingServer, $smtpUsername, $smtpPassword, $from, $to);
             } else {
                 if (CString::equalsCi($transport, "system")) {
                     $mail = CMail::makeSystem($from, $to);
                 } else {
                     assert('false', vs(isset($this), get_defined_vars()));
                 }
             }
             CShell::setMailing($mail);
         }
         $thirdPartyDp = $GLOBALS["PHRED_PATH_TO_THIRD_PARTY"];
         $lastUpdateTimeFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyLastUpdateTimeFn);
         // Read the file containing the Unix seconds of the last update time stamp (if exists) and compare that
         // time with the current time.
         $numDaysSinceLastUpdate;
         if (CFile::exists($lastUpdateTimeFp)) {
             $lastUpdateTime = new CTime(CString::toInt(CFile::read($lastUpdateTimeFp)));
             $currTime = CTime::now();
             if ($lastUpdateTime->isBefore($currTime)) {
                 $numDaysSinceLastUpdate = $currTime->diffInDays($lastUpdateTime);
                 if ($numDaysSinceLastUpdate < $minTimeBetweenDoUpdatesDays) {
                     // It is too early for updates yet.
                     return false;
                 }
             } else {
                 assert('false', vs(isset($this), get_defined_vars()));
             }
         }
         $date = CShell::currentDate();
         CShell::say("Started on {$date}.");
         if (isset($numDaysSinceLastUpdate)) {
             CShell::say("It has been {$numDaysSinceLastUpdate} day(s) since last successful update.");
         }
         $concurrLockFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyConcurrLockFn);
         // Try locking the operation.
         if (!self::setLock($concurrLockFp, false)) {
             assert('false', vs(isset($this), get_defined_vars()));
             CShell::onError(false, "Could not obtain a lock on the operation.");
             CShell::writeToLog("\n");
             return false;
         }
         $phpConfigNeedsReload = false;
         $totalNumComponents = CMap::length($components);
         $numComponentsUpdated = 0;
         // The Browser Capabilities Project (BrowsCap).
         if (CMap::hasKey($components, "browsCap")) {
             $browsCap = $components["browsCap"];
             $skip = $browsCap["skip"];
             if (!$skip) {
                 CShell::say("Updating the Browser Capabilities Project (BrowsCap) ...");
                 $lookupFileUrl = $browsCap["lookupFileUrl"];
                 assert('!CString::isEmpty($lookupFileUrl)', vs(isset($this), get_defined_vars()));
                 // Component-related constants.
                 static $s_configOptName = "browscap";
                 static $s_lookupFileDownloadTimeoutSeconds = 120;
                 if (self::hasConfigOption($s_configOptName)) {
                     $browsCapLookupFp = CString::trim(self::configOption($s_configOptName));
                     if (!CString::isEmpty($browsCapLookupFp)) {
                         $browsCapDp = CFilePath::directory($browsCapLookupFp);
                         CShell::say("Downloading a BrowsCap lookup file from '{$lookupFileUrl}' ...");
//.........这里部分代码省略.........
开发者ID:nunodotferreira,项目名称:Phred,代码行数:101,代码来源:CSystem.php

示例2: testReFindDirectoriesOnNameRecursive

 public function testReFindDirectoriesOnNameRecursive()
 {
     $directoryPath = CFilePath::add(CSystem::temporaryFilesDp(), CFile::DEFAULT_TEMPORARY_FILE_PREFIX . self::$ms_tempDirName);
     if (CFile::exists($directoryPath)) {
         CFile::deleteDirectoryRecursive($directoryPath);
     }
     CFile::createDirectory($directoryPath);
     CFile::create(CFilePath::add($directoryPath, "file-a3"));
     CFile::create(CFilePath::add($directoryPath, "file-a20"));
     CFile::create(CFilePath::add($directoryPath, "file-a100"));
     CFile::create(CFilePath::add($directoryPath, "file-b3"));
     CFile::create(CFilePath::add($directoryPath, "file-b20"));
     CFile::create(CFilePath::add($directoryPath, "file-b100"));
     $directoryPathSub0 = CFilePath::add($directoryPath, "dir-a2");
     $directoryPathSub1 = CFilePath::add($directoryPath, "dir-a10");
     $directoryPathSub2 = CFilePath::add($directoryPath, "dir-b2");
     $directoryPathSub3 = CFilePath::add($directoryPath, "dir-b10");
     CFile::createDirectory($directoryPathSub0);
     CFile::createDirectory(CFilePath::add($directoryPathSub0, "dir-a2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub0, "dir-a10"));
     CFile::createDirectory($directoryPathSub1);
     CFile::createDirectory(CFilePath::add($directoryPathSub1, "dir-a2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub1, "dir-a10"));
     CFile::createDirectory($directoryPathSub2);
     CFile::createDirectory(CFilePath::add($directoryPathSub2, "dir-b2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub2, "dir-b10"));
     CFile::createDirectory($directoryPathSub3);
     CFile::createDirectory(CFilePath::add($directoryPathSub3, "dir-b2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub3, "dir-b10"));
     $paths = CFile::reFindDirectoriesOnNameRecursive($directoryPath, "/^.*-b/");
     $comparator = function ($arrayString, $findString) {
         return $arrayString->endsWith($findString);
     };
     $this->assertTrue($paths->length() == 6);
     $this->assertTrue($paths->find("/dir-b2", $comparator) && $paths->find("/dir-b10", $comparator) && $paths->find("/dir-b2/dir-b2", $comparator) && $paths->find("/dir-b2/dir-b10", $comparator) && $paths->find("/dir-b10/dir-b2", $comparator) && $paths->find("/dir-b10/dir-b10", $comparator));
     $paths = CFile::reFindDirectoriesOnNameRecursive($directoryPath, "/^.*-b/", true);
     $this->assertTrue($paths->length() == 6);
     $this->assertTrue($paths[0]->endsWith("/dir-b2") && $paths[1]->endsWith("/dir-b10") && $paths[2]->endsWith("/dir-b2/dir-b2") && $paths[3]->endsWith("/dir-b2/dir-b10") && $paths[4]->endsWith("/dir-b10/dir-b2") && $paths[5]->endsWith("/dir-b10/dir-b10"));
     CFile::deleteDirectoryRecursive($directoryPath);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:40,代码来源:CFileTest.php

示例3: finalize

 protected function finalize()
 {
     if (is_resource($this->m_multiCurl)) {
         curl_multi_close($this->m_multiCurl);
     }
     if (isset($this->m_cookiesFp) && CFile::exists($this->m_cookiesFp)) {
         CFile::delete($this->m_cookiesFp);
     }
     $this->m_done = true;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CInetSession.php

示例4: finalize

 protected function finalize()
 {
     if ($this->m_done) {
         return;
     }
     if (is_resource($this->m_curl)) {
         curl_close($this->m_curl);
     }
     if (isset($this->m_downloadFile)) {
         $this->m_downloadFile->done();
     }
     if (isset($this->m_uploadFile)) {
         $this->m_uploadFile->done();
     }
     if (isset($this->m_fileUploadTempFp) && CFile::exists($this->m_fileUploadTempFp)) {
         CFile::delete($this->m_fileUploadTempFp);
     }
     $this->m_done = true;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:19,代码来源:CInetRequest.php

示例5: testAbsolute

 public function testAbsolute()
 {
     $directoryPath = CFilePath::add(CSystem::temporaryFilesDp(), CFile::DEFAULT_TEMPORARY_FILE_PREFIX . self::$ms_tempDirName);
     if (CFile::exists($directoryPath)) {
         CFile::deleteDirectoryRecursive($directoryPath);
     }
     CFile::createDirectory($directoryPath);
     $filePathAbs = CFilePath::add($directoryPath, "file");
     CFile::create($filePathAbs);
     CSystem::cd($directoryPath);
     $this->assertTrue(CFilePath::absolute("file")->equals(CFilePath::absolute($filePathAbs)));
     $this->assertTrue(CFilePath::absolute("./file")->equals(CFilePath::absolute($filePathAbs)));
     CFile::deleteDirectoryRecursive($directoryPath);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:14,代码来源:CFilePathTest.php


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