當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::opendir方法代碼示例

本文整理匯總了PHP中OC\Files\Filesystem::opendir方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::opendir方法的具體用法?PHP Filesystem::opendir怎麽用?PHP Filesystem::opendir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::opendir方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: copy

 /**
  * Copies a file or directory.
  *
  * This method must work recursively and delete the destination
  * if it exists
  *
  * @param string $source
  * @param string $destination
  * @return void
  */
 public function copy($source, $destination)
 {
     if (Filesystem::is_file($source)) {
         Filesystem::copy($source, $destination);
     } else {
         Filesystem::mkdir($destination);
         $dh = Filesystem::opendir($source);
         if (is_resource($dh)) {
             while (($subnode = readdir($dh)) !== false) {
                 if ($subnode == '.' || $subnode == '..') {
                     continue;
                 }
                 $this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
             }
         }
     }
     list($destinationDir, ) = \Sabre_DAV_URLUtil::splitPath($destination);
     $this->markDirty($destinationDir);
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:29,代碼來源:objecttree.php

示例2: getListing

 public function getListing($FOLDER, $showdel)
 {
     // Get the listing from the database
     $requery = false;
     $uid = \OCP\User::getUser();
     $query = \OCP\DB::prepare("SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name");
     $results = $query->execute(array($uid))->fetchAll();
     $results2 = $results;
     if ($results) {
         foreach ($results as $result) {
             foreach ($results2 as $result2) {
                 if ($result['id'] != $result2['id'] && $result['name'] == $result2['name'] && $result['grouping'] == $result2['grouping']) {
                     // We have a duplicate that should not exist. Need to remove the offending record first
                     $delid = -1;
                     if ($result['mtime'] == $result2['mtime']) {
                         // If the mtime's match, delete the oldest ID.
                         $delid = $result['id'];
                         if ($result['id'] > $result2['id']) {
                             $delid = $result2['id'];
                         }
                     } elseif ($result['mtime'] > $result2['mtime']) {
                         // Again, delete the oldest
                         $delid = $result2['id'];
                     } elseif ($result['mtime'] < $result2['mtime']) {
                         // The only thing left is if result is older
                         $delid = $result['id'];
                     }
                     if ($delid != -1) {
                         $delquery = \OCP\DB::prepare("DELETE FROM *PREFIX*ownnote WHERE id=?");
                         $delquery->execute(array($delid));
                         $requery = true;
                     }
                 }
             }
         }
     }
     if ($requery) {
         $query = \OCP\DB::prepare("SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name");
         $results = $query->execute(array($uid))->fetchAll();
         $requery = false;
     }
     // Tests to add a bunch of notes
     //$now = new DateTime();
     //for ($x = 0; $x < 199; $x++) {
     //saveNote('', "Test ".$x, '', '', $now->getTimestamp());
     //}
     $farray = array();
     if ($FOLDER != '') {
         // Create the folder if it doesn't exist
         if (!\OC\Files\Filesystem::is_dir($FOLDER)) {
             if (!\OC\Files\Filesystem::mkdir($FOLDER)) {
                 echo "ERROR: Could not create ownNote directory.";
                 exit;
             }
         }
         // Synchronize files to the database
         $filearr = array();
         if ($listing = \OC\Files\Filesystem::opendir($FOLDER)) {
             if (!$listing) {
                 echo "ERROR: Error listing directory.";
                 exit;
             }
             while (($file = readdir($listing)) !== false) {
                 $tmpfile = $file;
                 if ($tmpfile == "." || $tmpfile == "..") {
                     continue;
                 }
                 if (!$this->endsWith($tmpfile, ".htm") && !$this->endsWith($tmpfile, ".html")) {
                     continue;
                 }
                 if ($info = \OC\Files\Filesystem::getFileInfo($FOLDER . "/" . $tmpfile)) {
                     // Check for EVERNOTE but wait to rename them to get around:
                     // https://github.com/owncloud/core/issues/16202
                     if ($this->endsWith($tmpfile, ".html")) {
                         $this->checkEvernote($FOLDER, $tmpfile);
                     }
                     // Separate the name and group name
                     $name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $tmpfile);
                     $group = "";
                     if (substr($name, 0, 1) == "[") {
                         $end = strpos($name, ']');
                         $group = substr($name, 1, $end - 1);
                         $name = substr($name, $end + 1, strlen($name) - $end + 1);
                         $name = trim($name);
                     }
                     // Set array for later checking
                     $filearr[] = $tmpfile;
                     // Check to see if the file is in the DB
                     $fileindb = false;
                     if ($results) {
                         foreach ($results as $result) {
                             if ($result['deleted'] == 0) {
                                 if ($name == $result['name'] && $group == $result['grouping']) {
                                     $fileindb = true;
                                     // If it is in the DB, check if the filesystem file is newer than the DB
                                     if ($result['mtime'] < $info['mtime']) {
                                         // File is newer, this could happen if a user updates a file
                                         $html = "";
                                         $html = \OC\Files\Filesystem::file_get_contents($FOLDER . "/" . $tmpfile);
                                         $this->saveNote('', $result['name'], $result['grouping'], $html, $info['mtime']);
//.........這裏部分代碼省略.........
開發者ID:tumstech,項目名稱:ownnote,代碼行數:101,代碼來源:backend.php

示例3: opendir

 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function opendir($path)
 {
     return \OC\Files\Filesystem::opendir($path);
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:7,代碼來源:filesystem.php

示例4: renameGroup

function renameGroup($FOLDER, $originalgroupname, $editgroupname) {
	$ret = "";
	if ($listing = \OC\Files\Filesystem::opendir($FOLDER)) {
		if (!$listing) {
			$ret .= "ERROR: Error listing directory.";
		} else {
			while (($file = readdir($listing)) !== false) {
				if (substr($file,0,1) == "[") {
					$group = "";
					$end = strpos($file, ']');
					$group = substr($file, 1, $end-1);
					if ($group == $originalgroupname) {
						$filename = substr($file, $end+1, strlen($file)-$end+1);
						$filename = trim($filename);
						$filename = "[".$editgroupname."] ".$filename;
						if (!\OC\Files\Filesystem::file_exists($FOLDER."/".$filename)) {
							if (\OC\Files\Filesystem::rename($FOLDER."/".$file, $FOLDER."/".$filename)) {
								$ret .= "SUCCESS";
							} else {
								$ret .= "FAIL";
							}
						} else {
							$ret .= "FAIL";
						}
					}
				}
			}
		}
	}
	return $ret;
}
開發者ID:pombredanne,項目名稱:ArcherSys,代碼行數:31,代碼來源:backend.php


注:本文中的OC\Files\Filesystem::opendir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。