diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-04-15 11:44:04 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-04-15 11:44:04 +0200 |
commit | a6a8e2c553bd2ba82c3d50f147a49793ed62b6f5 (patch) | |
tree | 895212df697022c2b4ed9159f43cff39605919d2 /lib/filecache.php | |
parent | c5b8a3eb94be7f7de948215cfdd24ee06690a07a (diff) | |
download | nextcloud-server-a6a8e2c553bd2ba82c3d50f147a49793ed62b6f5.tar.gz nextcloud-server-a6a8e2c553bd2ba82c3d50f147a49793ed62b6f5.zip |
add public api to get the file id from the cache
Diffstat (limited to 'lib/filecache.php')
-rw-r--r-- | lib/filecache.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/filecache.php b/lib/filecache.php index cdd91dcbfa4..24984c2ccff 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -281,6 +281,7 @@ class OC_FileCache{ /** * get the file id as used in the cache + * unlike the public getId, full paths are used here (/usename/files/foo instead of /foo) * @param string $path * @return int */ @@ -303,6 +304,39 @@ class OC_FileCache{ return -1; } } + + /** + * get the file id as used in the cache + * @param string path + * @param string root (optional) + * @return int + */ + public static function getId($path,$root=''){ + if(!$root){ + $root=OC_Filesystem::getRoot(); + } + if($root=='/'){ + $root=''; + } + $path=$root.$path; + return self::getFileId($path); + } + + /** + * get the file path from the id, relative to the home folder of the user + * @param int id + * @param string user (optional) + * @return string + */ + public static function getPath($id,$user=''){ + if(!$user){ + $user=OC_User::getUser(); + } + $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE id=? AND user=?'); + $result=$query->execute(array($id,$user)); + $row=$result->fetchRow(); + return $row['path']; + } /** * get the file id of the parent folder, taking into account '/' has no parent |