public function testMount() { OC_Filesystem::mount('OC_Filestorage_Local', self::getStorageData(), '/'); $this->assertEqual('/', OC_Filesystem::getMountPoint('/')); $this->assertEqual('/', OC_Filesystem::getMountPoint('/some/folder')); $this->assertEqual('', OC_Filesystem::getInternalPath('/')); $this->assertEqual('some/folder', OC_Filesystem::getInternalPath('/some/folder')); OC_Filesystem::mount('OC_Filestorage_Local', self::getStorageData(), '/some'); $this->assertEqual('/', OC_Filesystem::getMountPoint('/')); $this->assertEqual('/some/', OC_Filesystem::getMountPoint('/some/folder')); $this->assertEqual('/some/', OC_Filesystem::getMountPoint('/some/')); $this->assertEqual('/', OC_Filesystem::getMountPoint('/some')); $this->assertEqual('folder', OC_Filesystem::getInternalPath('/some/folder')); }
function getID($path) { // use the share table from the db to find the item source if the file was reshared because shared files //are not stored in the file cache. if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") { $path_parts = explode('/', $path, 5); $user = $path_parts[1]; $intPath = '/' . $path_parts[4]; $query = \OC_DB::prepare('SELECT `item_source` FROM `*PREFIX*share` WHERE `uid_owner` = ? AND `file_target` = ? '); $result = $query->execute(array($user, $intPath)); $row = $result->fetchRow(); $fileSource = $row['item_source']; } else { $fileSource = OC_Filecache::getId($path, ''); } return $fileSource; }
/** * get the mountpoint of the storage object for a path ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account * * @param string path * @return string */ public function getMountPoint($path) { return OC_Filesystem::getMountPoint($this->getAbsolutePath($path)); }
/** * @brief Get the internal path to pass to the storage filesystem call * @param string Source file path * @return Source file path with mount point stripped out */ private function getInternalPath($path) { $mountPoint = OC_Filesystem::getMountPoint($path); $internalPath = substr($path, strlen($mountPoint)); return $internalPath; }