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


PHP Folder::pwd方法代码示例

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


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

示例1: upload

 /**
  * This function is used to uplodad file in /uploads/YEAR/MONTH directory 
  * and to create Content record contextually.
  * 
  * 
  * @param type $inputfile
  * @param string $destfile
  * @return boolean
  */
 public function upload($inputfile, $destfile = null)
 {
     if (strlen(trim($inputfile['name'])) === 0) {
         return FALSE;
     }
     $filename = strtolower($inputfile['name']);
     $sourcefile = $inputfile['tmp_name'];
     $file = new \Cake\Filesystem\File($sourcefile, true, 0775);
     $CONTENT_YEAR = date('Y');
     $CONTENT_MONTH = date('m');
     $UPLOAD_DIR = $this->path;
     $folder_dest = new Folder($UPLOAD_DIR);
     if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_YEAR)) {
         $folder_dest->create($folder_dest->pwd() . DS . $CONTENT_YEAR);
     }
     $folder_dest->cd($CONTENT_YEAR);
     if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_MONTH)) {
         $folder_dest->create($folder_dest->pwd() . DS . $CONTENT_MONTH);
     }
     $folder_dest->cd($CONTENT_MONTH);
     $path = DS . $CONTENT_YEAR . DS . $CONTENT_MONTH . DS;
     $permittedFilename = $this->getPermittedFilename($UPLOAD_DIR . $path, $filename);
     $destfile = $folder_dest->pwd() . DS . $permittedFilename;
     if ($file->copy($destfile, true)) {
         return $path . $permittedFilename;
     } else {
         return FALSE;
     }
 }
开发者ID:aoliverio,项目名称:content,代码行数:38,代码来源:File.php

示例2: pwd

 /**
  * Returns the full path of the file.
  *
  * @return string Full path to the file
  */
 public function pwd()
 {
     if ($this->path === null) {
         $dir = $this->Folder->pwd();
         if (is_dir($dir)) {
             $this->path = $this->Folder->slashTerm($dir) . $this->name;
         }
     }
     return $this->path;
 }
开发者ID:wepbunny,项目名称:cake2,代码行数:15,代码来源:File.php

示例3: testAddTestDirectoryRecursiveWithNonPhp

 /**
  * testAddTestDirectoryRecursiveWithNonPhp
  *
  * @return void
  */
 public function testAddTestDirectoryRecursiveWithNonPhp()
 {
     $this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
     $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
     touch($Folder->path . DS . 'BackupTest.php~');
     touch($Folder->path . DS . 'SomeNotesTest.txt');
     touch($Folder->path . DS . 'NotHiddenTest.php');
     $suite = $this->getMock('Cake\\TestSuite\\TestSuite', ['addTestFile']);
     $suite->expects($this->exactly(1))->method('addTestFile');
     $suite->addTestDirectoryRecursive($Folder->pwd());
     $Folder->delete();
 }
开发者ID:Slayug,项目名称:castor,代码行数:17,代码来源:TestSuiteTest.php

示例4: main

 /**
  * main method
  *
  * @param  string $tempDir an other directory to clear of all folders and files, if desired
  * @return void
  */
 public function main($tempDir = null)
 {
     if (empty($tempDir)) {
         $tempDir = Configure::read('Attachments.tmpUploadsPath');
     }
     if (!Folder::isAbsolute($tempDir)) {
         $this->out('The path must be absolute, "' . $tempDir . '" given.');
         exit;
     }
     $Folder = new Folder();
     if ($Folder->cd($tempDir) === false) {
         $this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
         exit;
     }
     $dir = new Folder($tempDir);
     $folders = $dir->read();
     $files = $dir->findRecursive();
     $deletedFiles = 0;
     $deletedFolders = 0;
     $this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');
     foreach ($files as $filePath) {
         $file = new File($filePath);
         // only delete if last change is longer than 24 hours ago
         if ($file->lastChange() < time() - 24 * 60 * 60 && $file->delete()) {
             $deletedFiles++;
         }
         $file->close();
     }
     foreach ($folders[0] as $folderName) {
         $folder = new Folder($dir->pwd() . $folderName);
         // only delete if folder is empty
         if ($folder->dirsize() === 0 && $folder->delete()) {
             $deletedFolders++;
         }
     }
     $this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
 }
开发者ID:cleptric,项目名称:cake-attachments,代码行数:43,代码来源:CleanTempShell.php

示例5: dumpStaticFiles

 /**
  * Dump static files
  *
  * @param DOMDocument $domDocument
  *
  * @throws \Exception
  */
 protected function dumpStaticFiles(DOMDocument $domDocument)
 {
     $xpath = new DOMXPath($domDocument);
     $assetsNodeList = $xpath->query('/assetic/static/files/file');
     $validFlags = ['GLOB_MARK' => GLOB_MARK, 'GLOB_NOSORT' => GLOB_NOSORT, 'GLOB_NOCHECK' => GLOB_NOCHECK, 'GLOB_NOESCAPE' => GLOB_NOESCAPE, 'GLOB_BRACE' => GLOB_BRACE, 'GLOB_ONLYDIR' => GLOB_ONLYDIR, 'GLOB_ERR' => GLOB_ERR];
     /** @var $assetNode DOMElement */
     foreach ($assetsNodeList as $assetNode) {
         $source = strtr($assetNode->getElementsByTagName('source')->item(0)->nodeValue, $this->paths);
         $destination = strtr($assetNode->getElementsByTagName('destination')->item(0)->nodeValue, $this->paths);
         $flag = $assetNode->getElementsByTagName('source')->item(0)->getAttribute('flag');
         if (empty($flag)) {
             $flag = null;
         } else {
             if (!array_key_exists($flag, $validFlags)) {
                 throw new \Exception(sprintf('This flag "%s" not valid.', $flag));
             }
             $flag = $validFlags[$flag];
         }
         $des = new Folder(WWW_ROOT . $destination, true, 0777);
         $allFiles = glob($source, $flag);
         foreach ($allFiles as $src) {
             if (is_dir($src)) {
                 $srcFolder = new Folder($src);
                 $srcFolder->copy($des->pwd());
             } else {
                 $srcFile = new File($src);
                 $srcFile->copy($des->path . DS . $srcFile->name);
             }
             $this->out($src . ' <info> >>> </info> ' . WWW_ROOT . $destination);
         }
     }
 }
开发者ID:phpie,项目名称:assetic-plugin,代码行数:39,代码来源:DumpTask.php

示例6: save

 public function save($name, $dados = array())
 {
     $dir = new Folder(ROOT . DS . 'config' . DS . 'schema' . DS, true, 0777);
     $file = new File($dir->pwd() . $name);
     $file->write(implode("\n", $dados));
     $file->close();
 }
开发者ID:lucasnpinheiro,项目名称:Kiterp,代码行数:7,代码来源:GerarSqlShell.php

示例7: runjobs

 /**
  * Process the tasks when they need to run
  *
  * @access private
  * @return void
  */
 private function runjobs()
 {
     $dir = new Folder(TMP);
     // set processing flag so function takes place only once at any given time
     $processing = count($dir->find('\\.scheduler_running_flag'));
     $processingFlag = new File($dir->slashTerm($dir->pwd()) . '.scheduler_running_flag');
     if ($processing && time() - $processingFlag->lastChange() < $this->processingTimeout) {
         $this->out("Scheduler already running! Exiting.");
         return false;
     } else {
         $processingFlag->delete();
         $processingFlag->create();
     }
     if (!$this->storePath) {
         $this->storePath = TMP;
     }
     // look for a store of the previous run
     $store = "";
     $storeFilePath = $this->storePath . $this->storeFile;
     if (file_exists($storeFilePath)) {
         $store = file_get_contents($storeFilePath);
     }
     $this->out('Reading from: ' . $storeFilePath);
     // build or rebuild the store
     if ($store != '') {
         $store = json_decode($store, true);
     } else {
         $store = $this->schedule;
     }
     // run the jobs that need to be run, record the time
     foreach ($this->schedule as $name => $job) {
         $now = new DateTime();
         $task = $job['task'];
         $action = $job['action'];
         // if the job has never been run before, create it
         if (!isset($store[$name])) {
             $store[$name] = $job;
         }
         // figure out the last run date
         $tmptime = $store[$name]['lastRun'];
         if ($tmptime == null) {
             $tmptime = new DateTime("1969-01-01 00:00:00");
         } elseif (is_array($tmptime)) {
             $tmptime = new DateTime($tmptime['date'], new DateTimeZone($tmptime['timezone']));
         } elseif (is_string($tmptime)) {
             $tmptime = new DateTime($tmptime);
         }
         // determine the next run time based on the last
         if (substr($job['interval'], 0, 1) === 'P') {
             $tmptime->add(new DateInterval($job['interval']));
             // "P10DT4H" http://www.php.net/manual/en/class.dateinterval.php
         } else {
             $tmptime->modify($job['interval']);
             // "next day 10:30" http://www.php.net/manual/en/datetime.formats.relative.php
         }
         // is it time to run? has it never been run before?
         if ($tmptime <= $now) {
             $this->hr();
             $this->out("Running {$name}");
             $this->hr();
             if (!isset($this->{$task})) {
                 $this->{$task} = $this->Tasks->load($task);
                 // load models if they aren't already
                 // foreach ($this->$task->uses as $mk => $mv) {
                 // 	if (!isset($this->$task->$mv)) {
                 // 		App::uses('AppModel', 'Model');
                 // 		App::uses($mv, 'Model');
                 // 		$this->$task->$mv = new $mv();
                 // 	}
                 // }
             }
             // grab the entire schedule record incase it was updated..
             $store[$name] = $this->schedule[$name];
             // execute the task and store the result
             $store[$name]['lastResult'] = call_user_func_array(array($this->{$task}, $action), $job['args']);
             // assign it the current time
             $now = new DateTime();
             $store[$name]['lastRun'] = $now->format('Y-m-d H:i:s');
         }
     }
     // write the store back to the file
     file_put_contents($this->storePath . $this->storeFile, json_encode($store));
     // remove processing flag
     $processingFlag->delete();
 }
开发者ID:kajas90,项目名称:cakephp-scheduler,代码行数:91,代码来源:SchedulerShell.php

示例8: sync

 public function sync($id = null)
 {
     $folder = new Folder();
     $folders_to_copy = ['f1' => ['dev' => '../src', 'prod' => '../../production/src'], 'f2' => ['dev' => '../plugins', 'prod' => '../../production/plugins'], 'f3' => ['dev' => '../webroot', 'prod' => '../../production/webroot'], 'f4' => ['dev' => '../config', 'prod' => '../../production/config']];
     $pass = 0;
     $fail = 0;
     foreach ($folders_to_copy as $ftc) {
         $p = new Folder($ftc['prod']);
         $d = new Folder($ftc['dev']);
         if ($folder->copy(['to' => $p->pwd(), 'from' => $d->pwd(), 'scheme' => Folder::MERGE])) {
             $pass++;
         } else {
             $fail++;
         }
     }
     if ($fail == 0) {
         $this->Flash->success(__('Production updated successfully.'));
     } else {
         $errors = '';
         foreach ($folder->errors() as $error) {
             $errors .= ' : ' . $error;
         }
         $this->Flash->error(__('Unable to update {0} folders on production. Errors' . $errors, $fail));
     }
     return $this->redirect($this->referer());
 }
开发者ID:jaambageek,项目名称:cakeboot-template,代码行数:26,代码来源:FilesController.php

示例9: testDirSize

 /**
  * testDirSize method
  *
  * @return void
  */
 public function testDirSize()
 {
     $path = TMP . 'tests' . DS;
     $Folder = new Folder($path . 'config_non_existent', true);
     $this->assertEquals(0, $Folder->dirSize());
     $File = new File($Folder->pwd() . DS . 'my.php', true, 0777);
     $File->create();
     $File->write('something here');
     $File->close();
     $this->assertEquals(14, $Folder->dirSize());
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:16,代码来源:FolderTest.php

示例10: _removeExpiredLock

 /**
  * _removeExpiredLock
  *
  * @return void
  */
 protected function _removeExpiredLock()
 {
     $dir = new Folder(CONFIG . $this->_config['lockout']['file_path'], true);
     $files = $dir->find();
     foreach ($files as $fileName) {
         $file = new File($dir->pwd() . DS . $fileName);
         $lastChange = Time::createFromTimestamp($file->lastChange());
         if ($lastChange->wasWithinLast($this->_config['lockout']['expires'])) {
             continue;
         }
         $file->delete();
     }
 }
开发者ID:crabstudio,项目名称:authenticate,代码行数:18,代码来源:AdvanceAuthenticate.php

示例11: deleteLetter

 private function deleteLetter($fileName)
 {
     $deleted = false;
     $filePath = WWW_ROOT . 'letters';
     try {
         $dir = new Folder($filePath);
         $file = new File($dir->pwd() . DS . $fileName);
         if ($file->delete()) {
             $deleted = true;
         }
     } catch (Exception $e) {
         $this->Flash->error(__('Ocurrió un error al tratar de borrar el archivo'));
         return $this->redirect(['action' => 'index']);
     }
     return $deleted;
 }
开发者ID:raguilar0,项目名称:TCU_FEUCR,代码行数:16,代码来源:SavingsController.php

示例12: delete

 public function delete($id = null)
 {
     if ($this->request->session()->read('Auth.User.role') == 'rep' || $this->request->session()->read('Auth.User.role') == 'admin') {
         try {
             $invoice = $this->Invoices->get($id);
         } catch (RecordNotFoundException $record) {
             $this->Flash->error(__('La información que está tratando de recuperar no existe en la base de datos. Verifique e intente de nuevo'));
             return $this->redirect(['controller' => 'Associations', 'action' => 'init']);
         }
         $deleted = false;
         $filePath = WWW_ROOT . '/img/invoices';
         $dir = new Folder($filePath);
         $file = new File($dir->pwd() . DS . $invoice['image_name']);
         if ($file->delete()) {
             $deleted = true;
         }
         if (!$this->Invoices->delete($invoice)) {
             $response = "0";
         } else {
             if ($this->request->session()->read('Auth.User.role') == 'rep') {
                 return $this->redirect(['action' => 'modify']);
             } else {
                 return $this->redirect(['action' => 'admin-modify']);
             }
         }
     } else {
         return $this->redirect(['controller' => 'pages', 'action' => 'home']);
     }
 }
开发者ID:raguilar0,项目名称:TCU_FEUCR,代码行数:29,代码来源:InvoicesController.php

示例13: testSortByName

 /**
  * Verify that the order using name is correct.
  */
 public function testSortByName()
 {
     $Folder = new Folder(TMP . 'tests', true);
     $fileA = new File($Folder->pwd() . DS . 'a.txt');
     $fileA->create();
     $fileC = new File($Folder->pwd() . DS . 'c.txt');
     $fileC->create();
     sleep(1);
     $fileB = new File($Folder->pwd() . DS . 'b.txt');
     $fileB->create();
     $results = $Folder->find('.*', Folder::SORT_NAME);
     $this->assertSame(['a.txt', 'b.txt', 'c.txt'], $results);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:16,代码来源:FolderTest.php


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