コード例 #1
0
 /**
  * Copy a file or folder in the cache
  *
  * @param \OCP\Files\Cache\ICache $sourceCache
  * @param ICacheEntry $sourceEntry
  * @param string $targetPath
  */
 public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, $targetPath)
 {
     $this->put($targetPath, $this->cacheEntryToArray($sourceEntry));
     if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
         $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId());
         foreach ($folderContent as $subEntry) {
             $subTargetPath = $targetPath . '/' . $subEntry->getName();
             $this->copyFromCache($sourceCache, $subEntry, $subTargetPath);
         }
     }
 }
コード例 #2
0
 /**
  * get the metadata of all files stored in $folder
  *
  * @param int $fileId the file id of the folder
  * @return array
  */
 public function getFolderContentsById($fileId)
 {
     $results = $this->cache->getFolderContentsById($fileId);
     return array_map(array($this, 'formatCacheEntry'), $results);
 }