/** * Determine permissions for a given file path * @param string $path * @return int */ function getPermissions($path) { // add read permissions $permissions = \OCP\PERMISSION_READ; // get directory $fileInfo = pathinfo($path); $dir = $fileInfo['dirname'] . '/'; // add update permissions if (Filesystem::isUpdatable($dir)) { $permissions |= \OCP\PERMISSION_UPDATE; } // add delete permissions if (Filesystem::isDeletable($dir)) { $permissions |= \OCP\PERMISSION_DELETE; } // add share permissions if (Filesystem::isSharable($dir)) { $permissions |= \OCP\PERMISSION_SHARE; } // return return $permissions; }
\OC::$session->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::isDeletable($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) { OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats))); } else { OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats))); }
/** * Delete the current file * * @return void * @throws Sabre_DAV_Exception_Forbidden */ public function delete() { if ($this->path === 'Shared') { throw new \Sabre_DAV_Exception_Forbidden(); } if (!\OC\Files\Filesystem::isDeletable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } \OC\Files\Filesystem::unlink($this->path); // remove properties $this->removeProperties(); }
/** * Deletes all files in this directory, and then itself * * @return void * @throws Sabre_DAV_Exception_Forbidden */ public function delete() { if ($this->path === 'Shared') { throw new \Sabre_DAV_Exception_Forbidden(); } if (!\OC\Files\Filesystem::isDeletable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } \OC\Files\Filesystem::rmdir($this->path); }
/** * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem */ public static function isDeletable($path) { return \OC\Files\Filesystem::isDeletable($path); }
/** * 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; }
/** * Delete the current file * * @return void * @throws Sabre_DAV_Exception_Forbidden */ public function delete() { if (!\OC\Files\Filesystem::isDeletable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } \OC\Files\Filesystem::unlink($this->path); }
$list = new OCP\Template('files', 'part.list', ''); $list->assign('files', $files); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); $list->assign('disableSharing', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?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; } if ($needUpgrade) { OCP\Util::addscript('files', 'upgrade'); $tmpl = new OCP\Template('files', 'upgrade', 'user'); $tmpl->printPage(); } else { // information about storage capacities $storageInfo = OC_Helper::getStorageInfo(); $maxUploadFilesize = OCP\Util::maxUploadFilesize($dir); OCP\Util::addscript('files', 'fileactions'); OCP\Util::addscript('files', 'files');
/** * Deletes all files in this directory, and then itself * * @return void * @throws Sabre_DAV_Exception_Forbidden */ public function delete() { if (!\OC\Files\Filesystem::isDeletable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } if ($this->path != "/Shared") { foreach ($this->getChildren() as $child) { $child->delete(); } \OC\Files\Filesystem::rmdir($this->path); } }