本文整理汇总了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);
}
示例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']);
//.........这里部分代码省略.........
示例3: opendir
/**
* @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
*/
public static function opendir($path)
{
return \OC\Files\Filesystem::opendir($path);
}
示例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;
}