示例#1
0
 /**
  * @param File|Folder $path
  */
 protected function pathCreateChecks($path)
 {
     // Make sure that we do not share a path that contains a shared mountpoint
     if ($path instanceof \OCP\Files\Folder) {
         $mounts = $this->mountManager->findIn($path->getPath());
         foreach ($mounts as $mount) {
             if ($mount->getStorage()->instanceOfStorage('\\OCA\\Files_Sharing\\ISharedStorage')) {
                 throw new \InvalidArgumentException('Path contains files shared with you');
             }
         }
     }
 }
示例#2
0
 /**
  * Determines if we've reached the root folder
  *
  * @param Folder $folder
  * @param int $level
  *
  * @return bool
  */
 protected function isRootFolder($folder, $level)
 {
     $isRootFolder = false;
     $rootFolder = $this->environment->getVirtualRootFolder();
     if ($folder->getPath() === $rootFolder->getPath()) {
         $isRootFolder = true;
     }
     $virtualRootFolder = $this->environment->getPathFromVirtualRoot($folder);
     if (empty($virtualRootFolder)) {
         $this->virtualRootLevel = $level;
     }
     return $isRootFolder;
 }
 /**
  * Returns the path which goes from the file, up to the user folder, based on a path:
  * parent_folder/current_folder/my_file
  *
  * getPath() on the file produces a path like:
  * '/userId/files/my_folder/my_sub_folder/my_file'
  *
  * So we substract the path to the user folder, giving us a relative path
  * 'my_folder/my_sub_folder'
  *
  * @param string $fullPath
  *
  * @return string
  */
 private function getRelativePath($fullPath)
 {
     $folderPath = $this->userFolder->getPath() . '/';
     $origShareRelPath = str_replace($folderPath, '', $fullPath);
     return $origShareRelPath;
 }