1 | <?php |
||
45 | class FileBackend |
||
46 | { |
||
47 | /** |
||
48 | * @access protected |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $path; |
||
52 | |||
53 | /** |
||
54 | * Constructs the object |
||
55 | * |
||
56 | * @access public |
||
57 | * @param string $path |
||
58 | */ |
||
59 | 12 | public function __construct($path) |
|
63 | |||
64 | /** |
||
65 | * Saves the content to the file |
||
66 | * |
||
67 | * @access public |
||
68 | * @param string $content |
||
69 | * @param string $additionalPath |
||
70 | * @return integer |
||
71 | * |
||
72 | * @throws Zepi\Turbo\Exception The file "$path" isn't writable! |
||
73 | */ |
||
74 | 5 | public function saveToFile($content, $additionalPath = '') |
|
88 | |||
89 | /** |
||
90 | * Loads the content from the file |
||
91 | * |
||
92 | * @access public |
||
93 | * @param string $additionalPath |
||
94 | * @return string |
||
95 | */ |
||
96 | 5 | public function loadFromFile($additionalPath = '') |
|
106 | |||
107 | /** |
||
108 | * Deletes a file on the hard disk. |
||
109 | * |
||
110 | * @access public |
||
111 | * @param string $additionalPath |
||
112 | * @return boolean |
||
113 | */ |
||
114 | 4 | public function deleteFile($additionalPath = '') |
|
124 | |||
125 | /** |
||
126 | * Returns true if a file or a directory exists and |
||
127 | * is writable. Otherwise return false. |
||
128 | * |
||
129 | * @access public |
||
130 | * @param string $additionalPath |
||
131 | * @return boolean |
||
132 | */ |
||
133 | 4 | public function isWritable($additionalPath = '') |
|
143 | |||
144 | /** |
||
145 | * Returns the real path for the given additional path and the |
||
146 | * file path which was given to the backend in the constructor. |
||
147 | * |
||
148 | * @access public |
||
149 | * @param string $additionalPath |
||
150 | * @return string |
||
151 | */ |
||
152 | 12 | protected function realPath($additionalPath) |
|
164 | |||
165 | /** |
||
166 | * If the path exists return the path. Otherwise return false |
||
167 | * or throw an exception. |
||
168 | * |
||
169 | * @access protected |
||
170 | * @param string $path |
||
171 | * @return false|string |
||
172 | * |
||
173 | * @throws \Zepi\Turbo\Exception The file path "{path}" is not readable and not writeable! |
||
174 | */ |
||
175 | 7 | protected function testPath($path) |
|
187 | |||
188 | /** |
||
189 | * Creates the target directory |
||
190 | * |
||
191 | * @access protected |
||
192 | * @param string $path |
||
193 | * |
||
194 | * @throws \Zepi\Turbo\Exception The directory "{directory}" doesn't exists |
||
195 | */ |
||
196 | 5 | protected function createTargetDirectory($path) |
|
207 | |||
208 | /** |
||
209 | * Returns the existing part of a path |
||
210 | * |
||
211 | * @access protected |
||
212 | * @param string $path |
||
213 | * @return string |
||
214 | */ |
||
215 | 2 | protected function getExistingPath($path) |
|
228 | } |
||
229 |