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

Directory class. More...

+ Inheritance diagram for Sabre\DAV\FS\Directory:
+ Collaboration diagram for Sabre\DAV\FS\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...
 
 getChildren ()
 Returns an array with all the child nodes. More...
 
 childExists ($name)
 Checks if a child exists. More...
 
 delete ()
 Deletes all files in this directory, and then itself. More...
 
 getQuotaInfo ()
 Returns available diskspace information. 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...
 

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 14 of file Directory.php.

Member Function Documentation

◆ childExists()

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

Checks if a child exists.

Parameters
string$name
Returns
bool

Implements Sabre\DAV\ICollection.

Definition at line 118 of file Directory.php.

118 {
119
120 $path = $this->path . '/' . $name;
121 return file_exists($path);
122
123 }

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

◆ createDirectory()

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

Creates a new subdirectory.

Parameters
string$name
Returns
void

Implements Sabre\DAV\ICollection.

Definition at line 54 of file Directory.php.

54 {
55
56 $newPath = $this->path . '/' . $name;
57 mkdir($newPath);
58 clearstatcache(true, $newPath);
59
60 }

References $name.

◆ createFile()

Sabre\DAV\FS\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 40 of file Directory.php.

40 {
41
42 $newPath = $this->path . '/' . $name;
43 file_put_contents($newPath, $data);
44 clearstatcache(true, $newPath);
45
46 }
$data
Definition: bench.php:6

References $data, and $name.

◆ delete()

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

Deletes all files in this directory, and then itself.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 130 of file Directory.php.

130 {
131
132 foreach ($this->getChildren() as $child) $child->delete();
133 rmdir($this->path);
134
135 }
getChildren()
Returns an array with all the child nodes.
Definition: Directory.php:95

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

+ Here is the call graph for this function:

◆ getChild()

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

Returns a specific child node, referenced by its name.

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

Parameters
string$name
Exceptions
DAV

Exception\NotFound

Returns
DAV\INode

Implements Sabre\DAV\ICollection.

Definition at line 72 of file Directory.php.

72 {
73
74 $path = $this->path . '/' . $name;
75
76 if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
77
78 if (is_dir($path)) {
79
80 return new self($path);
81
82 } else {
83
84 return new File($path);
85
86 }
87
88 }

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

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

+ Here is the caller graph for this function:

◆ getChildren()

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

Returns an array with all the child nodes.

Returns
DAV\INode[]

Implements Sabre\DAV\ICollection.

Definition at line 95 of file Directory.php.

95 {
96
97 $nodes = [];
98 $iterator = new \FilesystemIterator(
99 $this->path,
100 \FilesystemIterator::CURRENT_AS_SELF
101 | \FilesystemIterator::SKIP_DOTS
102 );
103 foreach ($iterator as $entry) {
104
105 $nodes[] = $this->getChild($entry->getFilename());
106
107 }
108 return $nodes;
109
110 }
getChild($name)
Returns a specific child node, referenced by its name.
Definition: Directory.php:72

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

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

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

◆ getQuotaInfo()

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

Returns available diskspace information.

Returns
array

Implements Sabre\DAV\IQuota.

Definition at line 142 of file Directory.php.

142 {
143 $absolute = realpath($this->path);
144 return [
145 disk_total_space($absolute) - disk_free_space($absolute),
146 disk_free_space($absolute)
147 ];
148
149 }

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