Gets a directory from the storage medium

@param  string  $path  The path of the directory

@return  Directory  A directory object

@throws  NotADirectoryException if <tt>$path</tt> is not a directory
171463
public function getDirectory(string $path): Directory {
    if($this->isFile($path)) {
      throw new NotADirectoryException($path);
    }

    return $this->instantiateDir($path);
  }
1270214
public function getFolder($path = '')
    {
        $this->connect();

        $path = trim($path, '/');

        if (file_exists($this->scheme . '/' . $path))
        {

            $result = [ 'folders' => $this->listSubFolder($path), 'files' => $this->listFiles($path) ];

            $folder = new Folder($path, $result);

            return $folder;
        }

        return false;
    }
554953
protected function _findPath($path)
    {
        $path = $this->_unifyPath($path);
        $dirs = $this->_dirs;

        $file = null;

        foreach ($dirs as $dir) {
            if (is_readable(realpath($dir.DS.$path))) {
                $file = $dir.DS.$path;
                break;
            }
        }

        return $file;
    }
566845
public static function pickAppDir($path)
    {
        // when relational path.
        if ($path[0] !== '/') return $path;

        $root = null;
        foreach (self::$namespaces as $p => $ns) {
            if (strpos($path, $p) === 0) {
                if ($root === null || strlen($root) < strlen($p)) $root = $p;
            }
        }

        return $root ? $root : $path;
    }
720457
public function getUrl($path)
    {
        $path = $this->getPathFromUrl($path);
        $url = $this->storageUrl . $path;
        
        return $url;
    }
1373354
public function getFolder($path = '')
    {
        if (!array_key_exists($path,$this->folders)) {

            $this->folders[$path] = false;
            if (file_exists($this->baseFolder . '/' . $path)) {
                $result = ['folders' => $this->listSubFolder($path), 'files' => $this->listFiles($path)];

                $folder = new Folder($path, $result);

                $this->folders[$path] = $folder;

            }
        }

        return $this->folders[$path];

    }
32572
public function readDir(string $path): array
    {
        $path = $this->sanitizeDirPath($path);

        if (!$this->dirExists($path)) {
            throw new DirNotFoundException("Dir not found: '$path'");
        }

        $result = $this->readDirRaw($path);

        sort($result);

        return $result;
    }
370075
public function getFile($path)
    {
        $file = new File($this->getFileSystemId(), $this->getFullPath($path));
        $file->setServiceLocator($this->getServiceLocator());
        return $file;
    }
265880
public function getFile(string $path): File {
    if($this->isDir($path)) {
      throw new NotAFileException($path);
    }

    return $this->instantiateFile($path);
  }
126111
protected function createDirectory($path)
    {
        if (!File::isDirectory($path)) {
            File::makeDirectory($path, 0777, true, true);
        }

        return $this;
    }
975399
public static function at($path)
    {
        $file = new static($path);

        if (! $file->exists()) {
            throw new NonExistentFileException("File does not exist at $path");
        }

        if (! $file->isReadable()) {
            throw new FilePermissionsException("File not readable at $path");
        }

        return $file;
    }
278761
public function fileAt($path)
    {
        $file = $this->nodeAt($path);

        if (!$file instanceof File) {
            throw new NotFileException();
        }

        return $file;
    }
359631
public function locate($path)
    {
        $repository = $this->getRepository();

        if(!$repository->contains($path)){
            throw new \InvalidArgumentException(sprintf('Their is no path %s in repository.', $path));
        }

        $resource = $repository->get($path);

        if(!($resource instanceof FilesystemResource)){
            throw new \RuntimeException(['Expect %s! %s given', FilesystemResource::class, get_class($resource)]);
        }

        return $resource;
    }
500268
private function getImagePath($path)
    {
        if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
            return $path;
        }

        return $this->noImagePath;
    }
610476
public function getDirectoryName(string $path) : string
    {
        if (!$this->exists($path)) {
            throw new FileSystemException("File at path $path not found");
        }

        return pathinfo($path, PATHINFO_DIRNAME);
    }
787775
public function ls($path)
    {
        if (!$this->hasCheckout) {
            $this->checkout();
        }

        if ($path == '/') {
            $path = '';
        }

        if (false === file_exists($this->cwd . '/' . $path)) {
            throw new NotFoundException(sprintf('The path \'%s\' is not found in %s', $path, $this->cwd));
        }

        $finder = new Finder();
        $files = $finder->in($this->cwd . '/' . $path)->exclude(".git")->ignoreDotFiles(false)->depth('== 0');

        $filelist = array();
        $entries = array();
        foreach ($files as $file) {
            $log = $this->log(($path ? $path . '/' : '') . $file->getRelativePathname(), null, 1);

            $commit = reset($log);
            $kind = $file->isDir() ? VcsFileInfo::DIR : VcsFileInfo::FILE;
            $file = new VcsFileInfo($file->getFilename(), $this->getHead(), $kind);
            $file->setCommit($commit);

            $entries[] = $file;
        }

        return $entries;
    }
984365
public function setWorkingDirectory($path)
    {
        $path = $this->prefixDirectoryStack($path);

        if ($this->files->exists($path))
        {
            return $this->directoryStack[] = $path;
        }

        throw new DirectoryNotFoundException("Directory [{$path}] could not be found.");
    }