Пример #1
0
 /**
  * Returns a MOXMAN_Vfs_IFile instance based on the specified path.
  *
  * @param string $path Path of the file to retrive.
  * @return MOXMAN_Vfs_IFile File instance for the specified path.
  */
 public function getFile($path)
 {
     // Get file from cache
     if ($this->cache->has($path)) {
         return $this->cache->get($path);
     }
     // Never give access to the mc_access file
     if ($this->getConfig()->get("filesystem.local.access_file_name") === basename($path)) {
         throw new MOXMAN_Exception("Can't access the access_file_name.");
     }
     MOXMAN_Util_PathUtils::verifyPath($path, true);
     // Force the path to an absolute path
     $path = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $path);
     // If the path is out side the root then return null
     if (!MOXMAN_Util_PathUtils::isChildOf($path, $this->rootPath)) {
         $null = null;
         return $null;
     }
     // Create the file and put it in the cache
     $file = new MOXMAN_Vfs_Local_File($this, $path);
     $this->cache->put($path, $file);
     return $file;
 }
Пример #2
0
 /** @ignore */
 private function copyDir($from, $to)
 {
     $fromPathRoot = $from->getPath();
     $files = $this->getFiles($fromPathRoot);
     foreach ($files as $fromPath) {
         $toPath = MOXMAN_Util_PathUtils::combine($to->getPath(), substr($fromPath, strlen($fromPathRoot)));
         if (is_file($fromPath)) {
             if ($to instanceof MOXMAN_Vfs_Local_File) {
                 copy($fromPath, $toPath);
             } else {
                 $to->getFileSystem()->getFile($toPath)->importFrom($fromPath);
             }
         } else {
             if ($to instanceof MOXMAN_Vfs_Local_File) {
                 MOXMAN_Util_PathUtils::verifyPath($toPath, true, "dir");
                 mkdir($toPath);
             } else {
                 $to->getFileSystem()->getFile($toPath)->mkdir();
             }
         }
     }
 }