1<?php 2 3namespace League\Flysystem; 4 5/** 6 * @deprecated 7 */ 8class File extends Handler 9{ 10 /** 11 * Check whether the file exists. 12 * 13 * @return bool 14 */ 15 public function exists() 16 { 17 return $this->filesystem->has($this->path); 18 } 19 20 /** 21 * Read the file. 22 * 23 * @return string|false file contents 24 */ 25 public function read() 26 { 27 return $this->filesystem->read($this->path); 28 } 29 30 /** 31 * Read the file as a stream. 32 * 33 * @return resource|false file stream 34 */ 35 public function readStream() 36 { 37 return $this->filesystem->readStream($this->path); 38 } 39 40 /** 41 * Write the new file. 42 * 43 * @param string $content 44 * 45 * @return bool success boolean 46 */ 47 public function write($content) 48 { 49 return $this->filesystem->write($this->path, $content); 50 } 51 52 /** 53 * Write the new file using a stream. 54 * 55 * @param resource $resource 56 * 57 * @return bool success boolean 58 */ 59 public function writeStream($resource) 60 { 61 return $this->filesystem->writeStream($this->path, $resource); 62 } 63 64 /** 65 * Update the file contents. 66 * 67 * @param string $content 68 * 69 * @return bool success boolean 70 */ 71 public function update($content) 72 { 73 return $this->filesystem->update($this->path, $content); 74 } 75 76 /** 77 * Update the file contents with a stream. 78 * 79 * @param resource $resource 80 * 81 * @return bool success boolean 82 */ 83 public function updateStream($resource) 84 { 85 return $this->filesystem->updateStream($this->path, $resource); 86 } 87 88 /** 89 * Create the file or update if exists. 90 * 91 * @param string $content 92 * 93 * @return bool success boolean 94 */ 95 public function put($content) 96 { 97 return $this->filesystem->put($this->path, $content); 98 } 99 100 /** 101 * Create the file or update if exists using a stream. 102 * 103 * @param resource $resource 104 * 105 * @return bool success boolean 106 */ 107 public function putStream($resource) 108 { 109 return $this->filesystem->putStream($this->path, $resource); 110 } 111 112 /** 113 * Rename the file. 114 * 115 * @param string $newpath 116 * 117 * @return bool success boolean 118 */ 119 public function rename($newpath) 120 { 121 if ($this->filesystem->rename($this->path, $newpath)) { 122 $this->path = $newpath; 123 124 return true; 125 } 126 127 return false; 128 } 129 130 /** 131 * Copy the file. 132 * 133 * @param string $newpath 134 * 135 * @return File|false new file or false 136 */ 137 public function copy($newpath) 138 { 139 if ($this->filesystem->copy($this->path, $newpath)) { 140 return new File($this->filesystem, $newpath); 141 } 142 143 return false; 144 } 145 146 /** 147 * Get the file's timestamp. 148 * 149 * @return string|false The timestamp or false on failure. 150 */ 151 public function getTimestamp() 152 { 153 return $this->filesystem->getTimestamp($this->path); 154 } 155 156 /** 157 * Get the file's mimetype. 158 * 159 * @return string|false The file mime-type or false on failure. 160 */ 161 public function getMimetype() 162 { 163 return $this->filesystem->getMimetype($this->path); 164 } 165 166 /** 167 * Get the file's visibility. 168 * 169 * @return string|false The visibility (public|private) or false on failure. 170 */ 171 public function getVisibility() 172 { 173 return $this->filesystem->getVisibility($this->path); 174 } 175 176 /** 177 * Get the file's metadata. 178 * 179 * @return array|false The file metadata or false on failure. 180 */ 181 public function getMetadata() 182 { 183 return $this->filesystem->getMetadata($this->path); 184 } 185 186 /** 187 * Get the file size. 188 * 189 * @return int|false The file size or false on failure. 190 */ 191 public function getSize() 192 { 193 return $this->filesystem->getSize($this->path); 194 } 195 196 /** 197 * Delete the file. 198 * 199 * @return bool success boolean 200 */ 201 public function delete() 202 { 203 return $this->filesystem->delete($this->path); 204 } 205} 206