7 use Gaufrette\Filesystem as Gaufrette;
34 private function __construct(Gaufrette $gaufrette, $localPath =
'', $chroot =
'') {
35 $this->gaufrette = $gaufrette;
36 $this->localPath = rtrim($localPath,
"/\\");
37 $this->
chroot = $this->normalize($chroot);
42 return new self($this->gaufrette, $this->localPath, $this->getGaufrettePath(
$path));
52 private function isDirectory(
$path) {
53 $adapter = $this->gaufrette->getAdapter();
54 return $adapter->isDirectory($this->getGaufrettePath(
$path));
59 return !$this->isDirectory(
$path) &&
60 $this->gaufrette->has($this->getGaufrettePath(
$path));
66 return $this->gaufrette->read($this->getGaufrettePath(
$path));
74 if ($this->isDirectory(
$path)) {
75 throw new \RuntimeException(
"There is already a directory at that location: $path");
83 $keys = $this->gaufrette->listKeys($this->getGaufrettePath(
$path));
99 private function getFullPath(
$path =
'') {
100 $gaufrettePath = $this->normalize($this->getGaufrettePath(
$path));
101 return "$this->localPath/$gaufrettePath";
111 private function getGaufrettePath(
$path) {
112 return $this->normalize(
"$this->chroot/$path");
117 return include $this->getFullPath(
$path);
127 private function normalize(
$path) {
128 return trim(
$path,
"/");
133 $this->gaufrette->write($this->getGaufrettePath(
$path),
$content,
true);
144 return new self(
new Gaufrette(
new Local(
$path)),
$path);
153 return new self(
new Gaufrette(
new InMemory()));
A simple directory abstraction.
putContents($path, $content)
static createInMemory()
Shorthand for generating a new in-memory-only filesystem.
Represents a file that may or may not actually exist.
$content
Set robots.txt action.
static createLocal($path)
Shorthand for generating a new local filesystem.
A wrapper around Gaufrette that implements Elgg's filesystem API.