ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\FSExt\Directory Class Reference

Directory class. More...

+ Inheritance diagram for Sabre\DAV\FSExt\Directory:
+ Collaboration diagram for Sabre\DAV\FSExt\Directory:

Public Member Functions

 createFile ($name, $data=null)
 Creates a new file in the directory. More...
 
 createDirectory ($name)
 Creates a new subdirectory. More...
 
 getChild ($name)
 Returns a specific child node, referenced by its name. More...
 
 childExists ($name)
 Checks if a child exists. More...
 
 getChildren ()
 Returns an array with all the child nodes. More...
 
 delete ()
 Deletes all files in this directory, and then itself. More...
 
 getQuotaInfo ()
 Returns available diskspace information. More...
 
 moveInto ($targetName, $sourcePath, DAV\INode $sourceNode)
 Moves a node into this collection. More...
 
- Public Member Functions inherited from Sabre\DAV\FS\Node
 __construct ($path)
 Sets up the node, expects a full path name. More...
 
 getName ()
 Returns the name of the node. More...
 
 setName ($name)
 Renames the node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 
 delete ()
 Deleted the current node. More...
 
 getName ()
 Returns the name of the node. More...
 
 setName ($name)
 Renames the node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 
 createFile ($name, $data=null)
 Creates a new file in the directory. More...
 
 createDirectory ($name)
 Creates a new subdirectory. More...
 
 getChild ($name)
 Returns a specific child node, referenced by its name. More...
 
 getChildren ()
 Returns an array with all the child nodes. More...
 
 childExists ($name)
 Checks if a child-node with the specified name exists. More...
 
 getQuotaInfo ()
 Returns the quota information. More...
 
- Public Member Functions inherited from Sabre\DAV\IMoveTarget
 moveInto ($targetName, $sourcePath, INode $sourceNode)
 Moves a node into this collection. More...
 

Additional Inherited Members

- Protected Attributes inherited from Sabre\DAV\FS\Node
 $path
 

Detailed Description

Directory class.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 15 of file Directory.php.

Member Function Documentation

◆ childExists()

Sabre\DAV\FSExt\Directory::childExists (   $name)

Checks if a child exists.

Parameters
string$name
Returns
bool

Implements Sabre\DAV\ICollection.

Definition at line 108 of file Directory.php.

108 {
109
110 if ($name == '.' || $name == '..')
111 throw new DAV\Exception\Forbidden('Permission denied to . and ..');
112
113 $path = $this->path . '/' . $name;
114 return file_exists($path);
115
116 }

References $name, and Sabre\DAV\FS\Node\$path.

◆ createDirectory()

Sabre\DAV\FSExt\Directory::createDirectory (   $name)

Creates a new subdirectory.

Parameters
string$name
Returns
void

Implements Sabre\DAV\ICollection.

Definition at line 63 of file Directory.php.

63 {
64
65 // We're not allowing dots
66 if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..');
67 $newPath = $this->path . '/' . $name;
68 mkdir($newPath);
69 clearstatcache(true, $newPath);
70
71 }

References $name.

◆ createFile()

Sabre\DAV\FSExt\Directory::createFile (   $name,
  $data = null 
)

Creates a new file in the directory.

Data will either be supplied as a stream resource, or in certain cases as a string. Keep in mind that you may have to support either.

After successful creation of the file, you may choose to return the ETag of the new file here.

The returned ETag must be surrounded by double-quotes (The quotes should be part of the actual string).

If you cannot accurately determine the ETag, you should not return it. If you don't store the file exactly as-is (you're transforming it somehow) you should also not return an ETag.

This means that if a subsequent GET to this new file does not exactly return the same contents of what was submitted here, you are strongly recommended to omit the ETag.

Parameters
string$nameName of the file
resource | string$dataInitial payload
Returns
null|string

Implements Sabre\DAV\ICollection.

Definition at line 41 of file Directory.php.

41 {
42
43 // We're not allowing dots
44 if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..');
45 $newPath = $this->path . '/' . $name;
46 file_put_contents($newPath, $data);
47 clearstatcache(true, $newPath);
48
49 return '"' . sha1(
50 fileinode($newPath) .
51 filesize($newPath) .
52 filemtime($newPath)
53 ) . '"';
54
55 }
$data
Definition: bench.php:6

References $data, and $name.

◆ delete()

Sabre\DAV\FSExt\Directory::delete ( )

Deletes all files in this directory, and then itself.

Returns
bool

Implements Sabre\DAV\INode.

Definition at line 146 of file Directory.php.

146 {
147
148 // Deleting all children
149 foreach ($this->getChildren() as $child) $child->delete();
150
151 // Removing the directory itself
152 rmdir($this->path);
153
154 return true;
155
156 }
getChildren()
Returns an array with all the child nodes.
Definition: Directory.php:123

References Sabre\DAV\FSExt\Directory\getChildren().

+ Here is the call graph for this function:

◆ getChild()

Sabre\DAV\FSExt\Directory::getChild (   $name)

Returns a specific child node, referenced by its name.

This method must throw Sabre\DAV\Exception\NotFound if the node does not exist.

Parameters
string$name
Exceptions
DAV

Exception\NotFound

Returns
DAV\INode

Implements Sabre\DAV\ICollection.

Reimplemented in Sabre\DAVACL\FS\Collection.

Definition at line 83 of file Directory.php.

83 {
84
85 $path = $this->path . '/' . $name;
86
87 if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located');
88 if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..');
89
90 if (is_dir($path)) {
91
92 return new self($path);
93
94 } else {
95
96 return new File($path);
97
98 }
99
100 }

References $name, and Sabre\DAV\FS\Node\$path.

Referenced by Sabre\DAV\FSExt\Directory\getChildren().

+ Here is the caller graph for this function:

◆ getChildren()

Sabre\DAV\FSExt\Directory::getChildren ( )

Returns an array with all the child nodes.

Returns
DAV\INode[]

Implements Sabre\DAV\ICollection.

Definition at line 123 of file Directory.php.

123 {
124
125 $nodes = [];
126 $iterator = new \FilesystemIterator(
127 $this->path,
128 \FilesystemIterator::CURRENT_AS_SELF
129 | \FilesystemIterator::SKIP_DOTS
130 );
131
132 foreach ($iterator as $entry) {
133
134 $nodes[] = $this->getChild($entry->getFilename());
135
136 }
137 return $nodes;
138
139 }
getChild($name)
Returns a specific child node, referenced by its name.
Definition: Directory.php:83

References $nodes, and Sabre\DAV\FSExt\Directory\getChild().

Referenced by Sabre\DAV\FSExt\Directory\delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuotaInfo()

Sabre\DAV\FSExt\Directory::getQuotaInfo ( )

Returns available diskspace information.

Returns
array

Implements Sabre\DAV\IQuota.

Definition at line 163 of file Directory.php.

163 {
164
165 $total = disk_total_space(realpath($this->path));
166 $free = disk_free_space(realpath($this->path));
167
168 return [
169 $total - $free,
170 $free
171 ];
172 }
$total
Definition: Utf8Test.php:87

References $total.

◆ moveInto()

Sabre\DAV\FSExt\Directory::moveInto (   $targetName,
  $sourcePath,
DAV\INode  $sourceNode 
)

Moves a node into this collection.

It is up to the implementors to:

  1. Create the new resource.
  2. Remove the old resource.
  3. Transfer any properties or other data.

Generally you should make very sure that your collection can easily move the move.

If you don't, just return false, which will trigger sabre/dav to handle the move itself. If you return true from this function, the assumption is that the move was successful.

Parameters
string$targetNameNew local file/collection name.
string$sourcePathFull path to source node
DAV\INode$sourceNodeSource node itself
Returns
bool

Definition at line 194 of file Directory.php.

194 {
195
196 // We only support FSExt\Directory or FSExt\File objects, so
197 // anything else we want to quickly reject.
198 if (!$sourceNode instanceof self && !$sourceNode instanceof File) {
199 return false;
200 }
201
202 // PHP allows us to access protected properties from other objects, as
203 // long as they are defined in a class that has a shared inheritence
204 // with the current class.
205 rename($sourceNode->path, $this->path . '/' . $targetName);
206
207 return true;
208
209 }

The documentation for this class was generated from the following file: