8 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
9 * @author Evert Pot (http://www.rooftopsolutions.nl/)
10 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
12 class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_PartialUpdate_IFile {
17 * data is a readable stream resource.
19 * @param resource|string $data
22 public function put($data) {
24 file_put_contents($this->path,$data);
25 return '"' . md5_file($this->path) . '"';
30 * Updates the data at a given offset
32 * The data argument is a readable stream resource.
33 * The offset argument is a 0-based offset where the data should be
36 * param resource|string $data
39 public function putRange($data, $offset) {
41 $f = fopen($this->path, 'c');
43 if (is_string($data)) {
46 stream_copy_to_stream($data,$f);
49 return '"' . md5_file($this->path) . '"';
58 public function get() {
60 return fopen($this->path,'r');
65 * Delete the current file
69 public function delete() {
72 return parent::delete();
77 * Returns the ETag for a file
79 * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
80 * The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
82 * Return null if the ETag can not effectively be determined
86 public function getETag() {
88 return '"' . md5_file($this->path). '"';
93 * Returns the mime-type for a file
95 * If null is returned, we'll assume application/octet-stream
99 public function getContentType() {
106 * Returns the size of the file, in bytes
110 public function getSize() {
112 return filesize($this->path);