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

File class. More...

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

Public Member Functions

 put ($data)
 Updates the data. More...
 
 patch ($data, $rangeType, $offset=null)
 Updates the file based on a range specification. More...
 
 get ()
 Returns the data. More...
 
 delete ()
 Delete the current file. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
 getSize ()
 Returns the size of the file, in bytes. 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...
 

Additional Inherited Members

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

Detailed Description

File class.

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

Definition at line 15 of file File.php.

Member Function Documentation

◆ delete()

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

Delete the current file.

Returns
bool

Implements Sabre\DAV\INode.

Definition at line 102 of file File.php.

102  {
103 
104  return unlink($this->path);
105 
106  }

◆ get()

Sabre\DAV\FSExt\File::get ( )

Returns the data.

Returns
resource

Implements Sabre\DAV\IFile.

Definition at line 91 of file File.php.

91  {
92 
93  return fopen($this->path, 'r');
94 
95  }

◆ getContentType()

Sabre\DAV\FSExt\File::getContentType ( )

Returns the mime-type for a file.

If null is returned, we'll assume application/octet-stream

Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 135 of file File.php.

135  {
136 
137  return null;
138 
139  }

◆ getETag()

Sabre\DAV\FSExt\File::getETag ( )

Returns the ETag for a file.

An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. The ETag is an arbitrary string, but MUST be surrounded by double-quotes.

Return null if the ETag can not effectively be determined

Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 118 of file File.php.

118  {
119 
120  return '"' . sha1(
121  fileinode($this->path) .
122  filesize($this->path) .
123  filemtime($this->path)
124  ) . '"';
125 
126  }

◆ getSize()

Sabre\DAV\FSExt\File::getSize ( )

Returns the size of the file, in bytes.

Returns
int

Implements Sabre\DAV\IFile.

Definition at line 146 of file File.php.

146  {
147 
148  return filesize($this->path);
149 
150  }

◆ patch()

Sabre\DAV\FSExt\File::patch (   $data,
  $rangeType,
  $offset = null 
)

Updates the file based on a range specification.

The first argument is the data, which is either a readable stream resource or a string.

The second argument is the type of update we're doing. This is either:

  • 1. append
  • 2. update based on a start byte
  • 3. update based on an end byte ; The third argument is the start or end byte.

After a successful put operation, you may choose to return an ETag. The ETAG must always be surrounded by double-quotes. These quotes must appear in the actual string you're returning.

Clients may use the ETag from a PUT request to later on make sure that when they update the file, the contents haven't changed in the mean time.

Parameters
resource | string$data
int$rangeType
int$offset
Returns
string|null

Implements Sabre\DAV\PartialUpdate\IPatchSupport.

Definition at line 60 of file File.php.

References $data, $f, and Sabre\DAV\File\getETag().

60  {
61 
62  switch ($rangeType) {
63  case 1 :
64  $f = fopen($this->path, 'a');
65  break;
66  case 2 :
67  $f = fopen($this->path, 'c');
68  fseek($f, $offset);
69  break;
70  case 3 :
71  $f = fopen($this->path, 'c');
72  fseek($f, $offset, SEEK_END);
73  break;
74  }
75  if (is_string($data)) {
76  fwrite($f, $data);
77  } else {
78  stream_copy_to_stream($data, $f);
79  }
80  fclose($f);
81  clearstatcache(true, $this->path);
82  return $this->getETag();
83 
84  }
getETag()
Returns the ETag for a file.
Definition: File.php:77
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ put()

Sabre\DAV\FSExt\File::put (   $data)

Updates the data.

Data is a readable stream resource.

Parameters
resource | string$data
Returns
string

Implements Sabre\DAV\IFile.

Definition at line 25 of file File.php.

References $data, and Sabre\DAV\File\getETag().

25  {
26 
27  file_put_contents($this->path, $data);
28  clearstatcache(true, $this->path);
29  return $this->getETag();
30 
31  }
getETag()
Returns the ETag for a file.
Definition: File.php:77
$data
Definition: bench.php:6
+ Here is the call graph for this function:

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