summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/Util.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/public/Util.php b/lib/public/Util.php
index 6cd3eaa7f85..ad8818df3ca 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -628,4 +628,45 @@ class Util {
}
return true;
}
+
+ /**
+ * @param int $id Id of the file returned by FileInfo::getId
+ */
+ public static function getDavFileId(int $id): string {
+ $instanceId = \OC_Util::getInstanceId();
+ $id = sprintf('%08d', $id);
+ return $id . $instanceId;
+ }
+
+ public static function getDavPermissions(\OCP\Files\FileInfo $info): string {
+ $p = '';
+ if ($info->isShared()) {
+ $p .= 'S';
+ }
+ if ($info->isShareable()) {
+ $p .= 'R';
+ }
+ if ($info->isMounted()) {
+ $p .= 'M';
+ }
+ if ($info->isReadable()) {
+ $p .= 'G';
+ }
+ if ($info->isDeletable()) {
+ $p .= 'D';
+ }
+ if ($info->isUpdateable()) {
+ $p .= 'NV'; // Renameable, Moveable
+ }
+ if ($info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
+ if ($info->isUpdateable()) {
+ $p .= 'W';
+ }
+ } else {
+ if ($info->isCreatable()) {
+ $p .= 'CK';
+ }
+ }
+ return $p;
+ }
}