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


PHP Filesystem::getDirectoryContent方法代码示例

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


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

示例1: getFiles

 public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '')
 {
     $contents = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter);
     if (isset($_SESSION['targetType']) && $_SESSION['targetType'] == TargetType::PROJECT) {
         /** @var FileInfo[] $subContents */
         $subContents = [];
         foreach ($contents as $content) {
             /** @var FileInfo $content */
             if ($content && $content->getMimetype() === 'httpd/unix-directory') {
                 $subDir = $dir . "/" . $content->getName();
                 $subContents = array_merge($subContents, \OC\Files\Filesystem::getDirectoryContent($subDir, $mimetypeFilter));
             }
         }
     }
     if (isset($subContents) && count($subContents) != 0) {
         $contents = array_merge($contents, $subContents);
     }
     $excludeFolder = [];
     foreach ($contents as $content) {
         /** @var FileInfo $content */
         if ($content && $content->getMimetype() === 'httpd/unix-directory') {
             continue;
         }
         array_push($excludeFolder, $content);
     }
     return self::sortFiles($excludeFolder, $sortAttribute, $sortDescending);
 }
开发者ID:fproject,项目名称:apps,代码行数:27,代码来源:helper.php

示例2: getFiles

 /**
  * Retrieves the contents of the given directory and
  * returns it as a sorted array.
  * @param string $dir path to the directory
  * @return array of files
  */
 public static function getFiles($dir)
 {
     $content = \OC\Files\Filesystem::getDirectoryContent($dir);
     $files = array();
     foreach ($content as $i) {
         $i['date'] = \OCP\Util::formatDate($i['mtime']);
         if ($i['type'] === 'file') {
             $fileinfo = pathinfo($i['name']);
             $i['basename'] = $fileinfo['filename'];
             if (!empty($fileinfo['extension'])) {
                 $i['extension'] = '.' . $fileinfo['extension'];
             } else {
                 $i['extension'] = '';
             }
         }
         $i['directory'] = $dir;
         $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
         $i['icon'] = \OCA\Files\Helper::determineIcon($i);
         $files[] = $i;
     }
     usort($files, array('\\OCA\\Files\\Helper', 'fileCmp'));
     return $files;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:29,代码来源:helper.php

示例3: addDirRecursive

 /**
  * Stream directory recursively
  * @param string $dir
  * @param string $internalDir
  */
 public function addDirRecursive($dir, $internalDir = '')
 {
     $dirname = basename($dir);
     $rootDir = $internalDir . $dirname;
     if (!empty($rootDir)) {
         $this->streamerInstance->addEmptyDir($rootDir);
     }
     $internalDir .= $dirname . '/';
     // prevent absolute dirs
     $internalDir = ltrim($internalDir, '/');
     $files = \OC\Files\Filesystem::getDirectoryContent($dir);
     foreach ($files as $file) {
         $filename = $file['name'];
         $file = $dir . '/' . $filename;
         if (\OC\Files\Filesystem::is_file($file)) {
             $filesize = \OC\Files\Filesystem::filesize($file);
             $fh = \OC\Files\Filesystem::fopen($file, 'r');
             $this->addFileFromStream($fh, $internalDir . $filename, $filesize);
             fclose($fh);
         } elseif (\OC\Files\Filesystem::is_dir($file)) {
             $this->addDirRecursive($file, $internalDir);
         }
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:29,代码来源:Streamer.php

示例4: zipAddDir

 /**
  * @param string $dir
  * @param ZipStreamer $zip
  * @param string $internalDir
  */
 public static function zipAddDir($dir, ZipStreamer $zip, $internalDir = '')
 {
     $dirname = basename($dir);
     $rootDir = $internalDir . $dirname;
     if (!empty($rootDir)) {
         $zip->addEmptyDir($rootDir);
     }
     $internalDir .= $dirname .= '/';
     // prevent absolute dirs
     $internalDir = ltrim($internalDir, '/');
     $files = \OC\Files\Filesystem::getDirectoryContent($dir);
     foreach ($files as $file) {
         $filename = $file['name'];
         $file = $dir . '/' . $filename;
         if (\OC\Files\Filesystem::is_file($file)) {
             $fh = \OC\Files\Filesystem::fopen($file, 'r');
             $zip->addFileFromStream($fh, $internalDir . $filename);
             fclose($fh);
         } elseif (\OC\Files\Filesystem::is_dir($file)) {
             self::zipAddDir($file, $zip, $internalDir);
         }
     }
 }
开发者ID:rosarion,项目名称:core,代码行数:28,代码来源:files.php

示例5: getFiles

 /**
  * Retrieves the contents of the given directory and
  * returns it as a sorted array of FileInfo.
  *
  * @param string $dir path to the directory
  * @param string $sortAttribute attribute to sort on
  * @param bool $sortDescending true for descending sort, false otherwise
  * @return \OCP\Files\FileInfo[] files
  */
 public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false)
 {
     $content = \OC\Files\Filesystem::getDirectoryContent($dir);
     return self::sortFiles($content, $sortAttribute, $sortDescending);
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:14,代码来源:helper.php

示例6: stripslashes

<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
// Get data
$dir = stripslashes($_POST["dir"]);
$allFiles = isset($_POST["allfiles"]) ? $_POST["allfiles"] : false;
// delete all files in dir ?
if ($allFiles === 'true') {
    $files = array();
    $fileList = \OC\Files\Filesystem::getDirectoryContent($dir);
    foreach ($fileList as $fileInfo) {
        $files[] = $fileInfo['name'];
    }
} else {
    $files = isset($_POST["file"]) ? $_POST["file"] : $_POST["files"];
    $files = json_decode($files);
}
$filesWithError = '';
$success = true;
//Now delete
foreach ($files as $file) {
    if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) && !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
        $filesWithError .= $file . "\n";
        $success = false;
    }
}
// get array with updated storage stats (e.g. max file size) after upload
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
if ($success) {
开发者ID:Combustible,项目名称:core,代码行数:31,代码来源:delete.php

示例7: testShareAndUnshareFromSelf

 /**
  * user1 share file to a group and to a user2 in the same group. Then user2
  * unshares the file from self. Afterwards user1 should no longer see the
  * single user share to user2. If he re-shares the file to user2 the same target
  * then the group share should be used to group the item
  */
 public function testShareAndUnshareFromSelf()
 {
     $fileinfo = $this->view->getFileInfo($this->filename);
     // share the file to group1 (user2 is a member of this group) and explicitely to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_ALL);
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user1 should have to shared files
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(2, count($shares));
     // user2 should have two files "welcome.txt" and the shared file,
     // both the group share and the single share of the same file should be
     // grouped to one file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
     // now user2 deletes the share (= unshare from self)
     \OC\Files\Filesystem::unlink($this->filename);
     // only welcome.txt should exists
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(1, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt'));
     // login as user1...
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // ... now user1 should have only one shared file, the group share
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(1, count($shares));
     // user1 shares a gain the file directly to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user2 should see again welcome.txt and the shared file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
 }
开发者ID:evanjt,项目名称:core,代码行数:41,代码来源:share.php

示例8: isset

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
// Check if we are a user
OCP\User::checkLoggedIn();
// Load the files we need
OCP\Util::addStyle("files", "files");
OCP\Util::addscript("files", "files");
// Load the files
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$files = array();
foreach (\OC\Files\Filesystem::getDirectoryContent($dir) as $i) {
    $i["date"] = date($CONFIG_DATEFORMAT, $i["mtime"]);
    $files[] = $i;
}
// Make breadcrumb
$breadcrumb = array();
$pathtohere = "/";
foreach (explode("/", $dir) as $i) {
    if ($i != "") {
        $pathtohere .= "{$i}/";
        $breadcrumb[] = array("dir" => $pathtohere, "name" => $i);
    }
}
// return template
$tmpl = new OCP\Template("files", "index", "user");
$tmpl->assign('files', $files);
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:settings.php

示例9: getChildren

 /**
  * Returns an array with all the child nodes
  *
  * @return Sabre_DAV_INode[]
  */
 public function getChildren()
 {
     $folder_content = \OC\Files\Filesystem::getDirectoryContent($this->path);
     $paths = array();
     foreach ($folder_content as $info) {
         $paths[] = $this->path . '/' . $info['name'];
         $properties[$this->path . '/' . $info['name']][self::GETETAG_PROPERTYNAME] = '"' . $info['etag'] . '"';
     }
     if (count($paths) > 0) {
         //
         // the number of arguments within IN conditions are limited in most databases
         // we chunk $paths into arrays of 200 items each to meet this criteria
         //
         $chunks = array_chunk($paths, 200, false);
         foreach ($chunks as $pack) {
             $placeholders = join(',', array_fill(0, count($pack), '?'));
             $query = OC_DB::prepare('SELECT * FROM `*PREFIX*properties`' . ' WHERE `userid` = ?' . ' AND `propertypath` IN (' . $placeholders . ')');
             array_unshift($pack, OC_User::getUser());
             // prepend userid
             $result = $query->execute($pack);
             while ($row = $result->fetchRow()) {
                 $propertypath = $row['propertypath'];
                 $propertyname = $row['propertyname'];
                 $propertyvalue = $row['propertyvalue'];
                 if ($propertyname !== self::GETETAG_PROPERTYNAME) {
                     $properties[$propertypath][$propertyname] = $propertyvalue;
                 }
             }
         }
     }
     $nodes = array();
     foreach ($folder_content as $info) {
         $node = $this->getChild($info['name'], $info);
         $node->setPropertyCache($properties[$this->path . '/' . $info['name']]);
         $nodes[] = $node;
     }
     return $nodes;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:43,代码来源:directory.php

示例10: validateZipDownload

 /**
  * checks if the selected files are within the size constraint. If not, outputs an error page.
  *
  * @param dir   $dir
  * @param files $files
  */
 static function validateZipDownload($dir, $files)
 {
     if (!OC_Config::getValue('allowZipDownload', true)) {
         $l = OC_L10N::get('lib');
         header("HTTP/1.0 409 Conflict");
         OC_Template::printErrorPage($l->t('ZIP download is turned off.'), $l->t('Files need to be downloaded one by one.') . '<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>');
         exit;
     }
     $zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
     if ($zipLimit > 0) {
         $totalsize = 0;
         if (!is_array($files)) {
             $files = array($files);
         }
         foreach ($files as $file) {
             $path = $dir . '/' . $file;
             if (\OC\Files\Filesystem::is_dir($path)) {
                 foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
                     $totalsize += $i['size'];
                 }
             } else {
                 $totalsize += \OC\Files\Filesystem::filesize($path);
             }
         }
         if ($totalsize > $zipLimit) {
             $l = OC_L10N::get('lib');
             header("HTTP/1.0 409 Conflict");
             OC_Template::printErrorPage($l->t('Selected files too large to generate zip file.'), $l->t('Please download the files separately in smaller chunks or kindly ask your administrator.') . '<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>');
             exit;
         }
     }
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:38,代码来源:files.php

示例11: array

<?php

// only need filesystem apps
$RUNTIME_APPTYPES = array('filesystem');
// Init owncloud
require_once 'lib/template.php';
OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
// make filelist
$files = array();
foreach (\OC\Files\Filesystem::getDirectoryContent($dir, $mimetype) as $i) {
    $i["date"] = OCP\Util::formatDate($i["mtime"]);
    $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir') : \mimetype_icon($i['mimetype']);
    $files[] = $i;
}
OCP\JSON::success(array('data' => $files));
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:18,代码来源:rawlist.php


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