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


PHP FileUtil::getTempDirectory方法代码示例

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


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

示例1: __construct

 /**
  * @param string $name lock name
  * @throws LockException
  */
 public function __construct($name)
 {
     $this->name = $name;
     $fileUtil = new FileUtil();
     $lockFile = $fileUtil->getTempDirectory() . DIRECTORY_SEPARATOR . $name;
     $this->handle = fopen($lockFile, "w");
     if (!is_resource($this->handle)) {
         throw new LockException("Could not open lock file {$lockFile}.");
     }
 }
开发者ID:bmdevel,项目名称:bav,代码行数:14,代码来源:Lock.php

示例2: testAutomaticUpdatePlan

 /**
  * @expectedException \PHPUnit_Framework_Error_Notice
  * @medium
  */
 public function testAutomaticUpdatePlan()
 {
     $fileUtil = new FileUtil();
     $file = tempnam($fileUtil->getTempDirectory(), 'bavtest');
     touch($file, strtotime("-1 year"));
     $backend = new FileDataBackend($file);
     $updatePlan = new AutomaticUpdatePlan();
     $this->assertTrue($updatePlan->isOutdated($backend));
     $updatePlan->perform($backend);
     $this->assertFalse($updatePlan->isOutdated($backend));
 }
开发者ID:bmdevel,项目名称:bav,代码行数:15,代码来源:00UpdatePlanTest.php

示例3: testAutomaticUpdate

 /**
  * Tests automatic installation.
  */
 public function testAutomaticUpdate()
 {
     $updatePlan = new AutomaticUpdatePlan();
     $updatePlan->setNotice(false);
     ConfigurationRegistry::getConfiguration()->setUpdatePlan($updatePlan);
     $fileUtil = new FileUtil();
     $container = new FileDataBackendContainer(tempnam($fileUtil->getTempDirectory(), 'bavtest'));
     $backend = $container->getDataBackend();
     touch($backend->getFile(), strtotime("-1 year"));
     $this->assertTrue($updatePlan->isOutdated($backend));
     $container->applyUpdatePlan($backend);
     $this->assertFalse($updatePlan->isOutdated($backend));
     $backend->uninstall();
     ConfigurationRegistry::getConfiguration()->setUpdatePlan(null);
 }
开发者ID:bmdevel,项目名称:bav,代码行数:18,代码来源:BackendContainerTest.php

示例4: downloadFile

 /**
  * Downloads a file.
  *
  * @param string $uri URI
  * @return string local path to downloaded file.
  * @throws DownloaderException
  */
 public function downloadFile($uri)
 {
     $fileUtil = new FileUtil();
     $file = tempnam($fileUtil->getTempDirectory(), "bavdownload");
     $fp = fopen($file, 'w');
     if (!($file && $fp)) {
         throw new DownloaderException("Failed opening a temporary file");
     }
     curl_setopt($this->handle, CURLOPT_FILE, $fp);
     if (!$this->download($uri)) {
         fclose($fp);
         unlink($file);
         throw new DownloaderException(curl_error($this->handle), curl_errno($this->handle));
     }
     return $file;
 }
开发者ID:bmdevel,项目名称:bav,代码行数:23,代码来源:Downloader.php

示例5: provideInstallationBackends

 /**
  * @return DataBackend[]
  */
 public function provideInstallationBackends()
 {
     $backends = array();
     $backends[] = new PDODataBackend(PDOFactory::makePDO(), "bavtest_");
     $fileUtil = new FileUtil();
     $backends[] = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), "bavtest"));
     $conn = array("driver" => "pdo_sqlite", "path" => ":memory:");
     $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true);
     $backends[] = new DoctrineDataBackend($doctrineContainer->getEntityManager());
     foreach ($backends as &$backend) {
         if ($backend->isInstalled()) {
             $backend->uninstall();
         }
         self::$freeableDatabackends[] = $backend;
         $backend = array($backend);
     }
     return $backends;
 }
开发者ID:bmdevel,项目名称:bav,代码行数:21,代码来源:BackendTest.php

示例6: update

 /**
  * @see DataBackend::update()
  * @throws DataBackendException
  */
 public function update()
 {
     $useTA = false;
     try {
         $fileUtil = new FileUtil();
         $fileBackend = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), 'bav'));
         $fileBackend->install();
         $insertBank = $this->pdo->prepare("INSERT INTO {$this->prefix}bank\n                    (id, validator, mainAgency)\n                    VALUES(:bankID, :validator, :mainAgency)");
         $insertAgency = $this->pdo->prepare("INSERT INTO {$this->prefix}agency\n                    (id, name, postcode, city, shortTerm, pan, bic, bank)\n                    VALUES (:id, :name, :postcode, :city, :shortTerm, :pan, :bic, :bank)");
         try {
             $this->pdo->beginTransaction();
             $useTA = true;
         } catch (\PDOException $e) {
             trigger_error("Your DBS doesn't support transactions. Your data may be corrupted.");
         }
         $this->pdo->exec("DELETE FROM {$this->prefix}agency");
         $this->pdo->exec("DELETE FROM {$this->prefix}bank");
         foreach ($fileBackend->getAllBanks() as $bank) {
             try {
                 $insertBank->execute(array(":bankID" => $bank->getBankID(), ":validator" => $bank->getValidationType(), ":mainAgency" => $bank->getMainAgency()->getID()));
                 $agencies = $bank->getAgencies();
                 $agencies[] = $bank->getMainAgency();
                 foreach ($agencies as $agency) {
                     $insertAgency->execute(array(":id" => $agency->getID(), ":name" => $agency->getName(), ":postcode" => $agency->getPostcode(), ":city" => $agency->getCity(), ":shortTerm" => $agency->getShortTerm(), ":bank" => $bank->getBankID(), ":pan" => $agency->hasPAN() ? $agency->getPAN() : null, ":bic" => $agency->hasBIC() ? $agency->getBIC() : null));
                 }
             } catch (NoMainAgencyException $e) {
                 trigger_error("Skipping bank {$e->getBank()->getBankID()} without any main agency.");
             }
         }
         // Update modification timestamp
         $modificationStmt = $this->pdo->prepare("UPDATE {$this->prefix}meta SET value=:value WHERE name=:name");
         $modificationStmt->execute(array(":name" => MetaData::LASTMODIFIED, ":value" => time()));
         if ($useTA) {
             $this->pdo->commit();
             $useTA = false;
         }
         $fileBackend->uninstall();
     } catch (Exception $e) {
         try {
             if ($useTA) {
                 $this->pdo->rollback();
             }
             throw $e;
         } catch (\PDOException $e2) {
             throw new DataBackendIOException(get_class($e) . ": {$e->getMessage()}\nadditionally: {$e2->getMessage()}");
         }
     }
 }
开发者ID:bmdevel,项目名称:bav,代码行数:52,代码来源:PDODataBackend.php

示例7: testLinuxTempDirectory

 /**
  * Tests getting /tmp.
  * 
  * @requires OS Linux
  */
 public function testLinuxTempDirectory()
 {
     $fileUtil = new FileUtil();
     $this->assertEquals("/tmp", $fileUtil->getTempDirectory());
 }
开发者ID:bmdevel,项目名称:bav,代码行数:10,代码来源:FileUtilTest.php


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