本文整理匯總了PHP中OC_Filesystem::opendir方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Filesystem::opendir方法的具體用法?PHP OC_Filesystem::opendir怎麽用?PHP OC_Filesystem::opendir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::opendir方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: scanFolder
/**
* scan a folder for music
* @param string $path
* @return int the number of songs found
*/
public static function scanFolder($path)
{
if (OC_Filesystem::is_dir($path)) {
$songs = 0;
if ($dh = OC_Filesystem::opendir($path)) {
while (($filename = readdir($dh)) !== false) {
if ($filename != '.' and $filename != '..' and substr($filename, 0, 1) != '.') {
$file = $path . '/' . $filename;
if (OC_Filesystem::is_dir($file)) {
$songs += self::scanFolder($file);
} elseif (OC_Filesystem::is_file($file)) {
$data = self::scanFile($file);
if ($data) {
$songs++;
}
}
}
}
}
} elseif (OC_Filesystem::is_file($path)) {
$songs = 1;
self::scanFile($path);
} else {
$songs = 0;
}
return $songs;
}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:32,代碼來源:owncloud_apps_media_lib_scanner.php
示例2: getChildren
/**
* Returns an array with all the child nodes
*
* @return Sabre_DAV_INode[]
*/
public function getChildren()
{
$nodes = array();
// foreach(scandir($this->path) as $node) if($node!='.' && $node!='..') $nodes[] = $this->getChild($node);
if (OC_Filesystem::is_dir($this->path . '/')) {
$dh = OC_Filesystem::opendir($this->path . '/');
while (($node = readdir($dh)) !== false) {
if ($node != '.' && $node != '..') {
$nodes[] = $this->getChild($node);
}
}
}
return $nodes;
}
示例3: getDirectoryContent
/**
* get the content of a directory
* @param dir $directory
*/
public static function getDirectoryContent($directory)
{
if (strpos($directory, OC::$CONFIG_DATADIRECTORY) === 0) {
$directory = substr($directory, strlen(OC::$CONFIG_DATADIRECTORY));
}
$filesfound = true;
$content = array();
$dirs = array();
$file = array();
$files = array();
if (OC_Filesystem::is_dir($directory)) {
if ($dh = OC_Filesystem::opendir($directory)) {
while (($filename = readdir($dh)) !== false) {
if ($filename != '.' and $filename != '..' and substr($filename, 0, 1) != '.') {
$file = array();
$filesfound = true;
$file['name'] = $filename;
$file['directory'] = $directory;
$stat = OC_Filesystem::stat($directory . '/' . $filename);
$file = array_merge($file, $stat);
$file['size'] = OC_Filesystem::filesize($directory . '/' . $filename);
$file['mime'] = OC_Files::getMimeType($directory . '/' . $filename);
$file['readable'] = OC_Filesystem::is_readable($directory . '/' . $filename);
$file['writeable'] = OC_Filesystem::is_writeable($directory . '/' . $filename);
$file['type'] = OC_Filesystem::filetype($directory . '/' . $filename);
if ($file['type'] == 'dir') {
$dirs[$file['name']] = $file;
} else {
$files[$file['name']] = $file;
}
}
}
closedir($dh);
}
}
uksort($dirs, "strnatcasecmp");
uksort($files, "strnatcasecmp");
$content = array_merge($dirs, $files);
if ($filesfound) {
return $content;
} else {
return false;
}
}
示例4: dirname
}
if (substr($query, -1, 1) == '/') {
$base = $query;
} else {
$base = dirname($query);
}
$query = substr($query, strlen($base));
if ($base != '/') {
$query = substr($query, 1);
}
$queryLen = strlen($query);
$query = strtolower($query);
// echo "$base - $query";
$files = array();
if (OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)) {
$dh = OC_Filesystem::opendir($base);
if ($dh) {
if (substr($base, -1, 1) != '/') {
$base = $base . '/';
}
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
if (substr(strtolower($file), 0, $queryLen) == $query) {
$item = $base . $file;
if (!$dirOnly or OC_Filesystem::is_dir($item)) {
$files[] = (object) array('id' => $item, 'label' => $item, 'name' => $item);
}
}
}
}
}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:31,代碼來源:owncloud_files_ajax_autocomplete.php
示例5: findMusic
function findMusic($path = '')
{
$music = array();
$dh = OC_Filesystem::opendir($path);
if ($dh) {
while ($filename = readdir($dh)) {
if ($filename[0] != '.') {
$file = $path . '/' . $filename;
if (OC_Filesystem::is_dir($file)) {
$music = array_merge($music, findMusic($file));
} else {
if (OC_MEDIA_SCANNER::isMusic($filename)) {
$music[] = $file;
}
}
}
}
}
return $music;
}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:20,代碼來源:owncloud_apps_media_ajax_api.php