// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
-if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
+if (!$dirInfo->getType() === 'dir') {
header("HTTP/1.0 404 Not Found");
exit();
}
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
// Make breadcrumb
if($doBreadcrumb) {
// Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
// Redirect if directory does not exist
-if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
+if (!$dirInfo->getType() === 'dir') {
header('Location: ' . OCP\Util::getScriptName() . '');
exit();
}
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
if ($needUpgrade) {
OCP\Util::addscript('files', 'upgrade');
}
return $breadcrumb;
}
-
- /**
- * Returns the numeric permissions for the given directory.
- * @param string $dir directory without trailing slash
- * @return numeric permissions
- */
- public static function getDirPermissions($dir){
- $permissions = \OCP\PERMISSION_READ;
- if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_CREATE;
- }
- if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_UPDATE;
- }
- if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_DELETE;
- }
- if (\OC\Files\Filesystem::isSharable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_SHARE;
- }
- return $permissions;
- }
}
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo
*/
public static function getFileInfo($path, $includeMountPoints = true) {
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);