d34e8735a1280933c798f7edcdb3000918b29d4c
2 namespace TYPO3\CMS\Core\
Resource\Driver
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
19 * An interface Drivers have to implement to fulfil the needs
22 interface DriverInterface
{
25 * Processes the configuration for this driver.
28 public function processConfiguration();
31 * Sets the storage uid the driver belongs to
33 * @param int $storageUid
36 public function setStorageUid($storageUid);
39 * Initializes this object. This is called by the storage after the driver
44 public function initialize();
47 * Returns the capabilities of this driver.
50 * @see Storage::CAPABILITY_* constants
52 public function getCapabilities();
55 * Merges the capabilities merged by the user at the storage
56 * configuration into the actual capabilities of the driver
57 * and returns the result.
59 * @param int $capabilities
62 public function mergeConfigurationCapabilities($capabilities);
65 * Returns TRUE if this driver has the given capability.
67 * @param int $capability A capability, as defined in a CAPABILITY_* constant
70 public function hasCapability($capability);
73 * Returns TRUE if this driver uses case-sensitive identifiers. NOTE: This
74 * is a configurable setting, but the setting does not change the way the
75 * underlying file system treats the identifiers; the setting should
76 * therefore always reflect the file system and not try to change its
81 public function isCaseSensitiveFileSystem();
84 * Cleans a fileName from not allowed characters
86 * @param string $fileName
87 * @param string $charset Charset of the a fileName
88 * (defaults to current charset; depending on context)
89 * @return string the cleaned filename
91 public function sanitizeFileName($fileName, $charset = '');
94 * Hashes a file identifier, taking the case sensitivity of the file system
95 * into account. This helps mitigating problems with case-insensitive
98 * @param string $identifier
101 public function hashIdentifier($identifier);
104 * Returns the identifier of the root level folder of the storage.
108 public function getRootLevelFolder();
111 * Returns the identifier of the default folder new files should be put into.
115 public function getDefaultFolder();
118 * Returns the identifier of the folder the file resides in
120 * @param string $fileIdentifier
123 public function getParentFolderIdentifierOfIdentifier($fileIdentifier);
126 * Returns the public URL to a file.
127 * Either fully qualified URL or relative to PATH_site (rawurlencoded).
129 * @param string $identifier
132 public function getPublicUrl($identifier);
135 * Creates a folder, within a parent folder.
136 * If no parent folder is given, a root level folder will be created
138 * @param string $newFolderName
139 * @param string $parentFolderIdentifier
140 * @param bool $recursive
141 * @return string the Identifier of the new folder
143 public function createFolder($newFolderName, $parentFolderIdentifier = '', $recursive = FALSE);
146 * Renames a folder in this storage.
148 * @param string $folderIdentifier
149 * @param string $newName
150 * @return array A map of old to new file identifiers of all affected resources
152 public function renameFolder($folderIdentifier, $newName);
155 * Removes a folder in filesystem.
157 * @param string $folderIdentifier
158 * @param bool $deleteRecursively
161 public function deleteFolder($folderIdentifier, $deleteRecursively = FALSE);
164 * Checks if a file exists.
166 * @param string $fileIdentifier
169 public function fileExists($fileIdentifier);
172 * Checks if a folder exists.
174 * @param string $folderIdentifier
177 public function folderExists($folderIdentifier);
180 * Checks if a folder contains files and (if supported) other folders.
182 * @param string $folderIdentifier
183 * @return bool TRUE if there are no files and folders within $folder
185 public function isFolderEmpty($folderIdentifier);
188 * Adds a file from the local server hard disk to a given path in TYPO3s
189 * virtual file system. This assumes that the local file exists, so no
190 * further check is done here! After a successful the original file must
193 * @param string $localFilePath (within PATH_site)
194 * @param string $targetFolderIdentifier
195 * @param string $newFileName optional, if not given original name is used
196 * @param bool $removeOriginal if set the original file will be removed
197 * after successful operation
198 * @return string the identifier of the new file
200 public function addFile($localFilePath, $targetFolderIdentifier, $newFileName = '', $removeOriginal = TRUE);
203 * Creates a new (empty) file and returns the identifier.
205 * @param string $fileName
206 * @param string $parentFolderIdentifier
209 public function createFile($fileName, $parentFolderIdentifier);
212 * Copies a file *within* the current storage.
213 * Note that this is only about an inner storage copy action,
214 * where a file is just copied to another folder in the same storage.
216 * @param string $fileIdentifier
217 * @param string $targetFolderIdentifier
218 * @param string $fileName
219 * @return string the Identifier of the new file
221 public function copyFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $fileName);
224 * Renames a file in this storage.
226 * @param string $fileIdentifier
227 * @param string $newName The target path (including the file name!)
228 * @return string The identifier of the file after renaming
230 public function renameFile($fileIdentifier, $newName);
233 * Replaces a file with file in local file system.
235 * @param string $fileIdentifier
236 * @param string $localFilePath
237 * @return bool TRUE if the operation succeeded
239 public function replaceFile($fileIdentifier, $localFilePath);
242 * Removes a file from the filesystem. This does not check if the file is
243 * still used or if it is a bad idea to delete it for some other reason
244 * this has to be taken care of in the upper layers (e.g. the Storage)!
246 * @param string $fileIdentifier
247 * @return bool TRUE if deleting the file succeeded
249 public function deleteFile($fileIdentifier);
252 * Creates a hash for a file.
254 * @param string $fileIdentifier
255 * @param string $hashAlgorithm The hash algorithm to use
258 public function hash($fileIdentifier, $hashAlgorithm);
262 * Moves a file *within* the current storage.
263 * Note that this is only about an inner-storage move action,
264 * where a file is just moved to another folder in the same storage.
266 * @param string $fileIdentifier
267 * @param string $targetFolderIdentifier
268 * @param string $newFileName
271 public function moveFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $newFileName);
275 * Folder equivalent to moveFileWithinStorage().
277 * @param string $sourceFolderIdentifier
278 * @param string $targetFolderIdentifier
279 * @param string $newFolderName
280 * @return array All files which are affected, map of old => new file identifiers
282 public function moveFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName);
285 * Folder equivalent to copyFileWithinStorage().
287 * @param string $sourceFolderIdentifier
288 * @param string $targetFolderIdentifier
289 * @param string $newFolderName
292 public function copyFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName);
295 * Returns the contents of a file. Beware that this requires to load the
296 * complete file into memory and also may require fetching the file from an
297 * external location. So this might be an expensive operation (both in terms
298 * of processing resources and money) for large files.
300 * @param string $fileIdentifier
301 * @return string The file contents
303 public function getFileContents($fileIdentifier);
306 * Sets the contents of a file to the specified value.
308 * @param string $fileIdentifier
309 * @param string $contents
310 * @return int The number of bytes written to the file
312 public function setFileContents($fileIdentifier, $contents);
315 * Checks if a file inside a folder exists
317 * @param string $fileName
318 * @param string $folderIdentifier
321 public function fileExistsInFolder($fileName, $folderIdentifier);
324 * Checks if a folder inside a folder exists.
326 * @param string $folderName
327 * @param string $folderIdentifier
330 public function folderExistsInFolder($folderName, $folderIdentifier);
333 * Returns a path to a local copy of a file for processing it. When changing the
334 * file, you have to take care of replacing the current version yourself!
336 * @param string $fileIdentifier
337 * @param bool $writable Set this to FALSE if you only need the file for read
338 * operations. This might speed up things, e.g. by using
339 * a cached local version. Never modify the file if you
340 * have set this flag!
341 * @return string The path to the file on the local disk
343 public function getFileForLocalProcessing($fileIdentifier, $writable = TRUE);
346 * Returns the permissions of a file/folder as an array
347 * (keys r, w) of boolean flags
349 * @param string $identifier
352 public function getPermissions($identifier);
355 * Directly output the contents of the file to the output
356 * buffer. Should not take care of header files or flushing
357 * buffer before. Will be taken care of by the Storage.
359 * @param string $identifier
362 public function dumpFileContents($identifier);
365 * Checks if a given identifier is within a container, e.g. if
366 * a file or folder is within another folder.
367 * This can e.g. be used to check for web-mounts.
369 * Hint: this also needs to return TRUE if the given identifier
370 * matches the container identifier to allow access to the root
371 * folder of a filemount.
373 * @param string $folderIdentifier
374 * @param string $identifier identifier to be checked against $folderIdentifier
375 * @return bool TRUE if $content is within or matches $folderIdentifier
377 public function isWithin($folderIdentifier, $identifier);
380 * Returns information about a file.
382 * @param string $fileIdentifier
383 * @param array $propertiesToExtract Array of properties which are be extracted
384 * If empty all will be extracted
387 public function getFileInfoByIdentifier($fileIdentifier, array $propertiesToExtract = array());
390 * Returns information about a file.
392 * @param string $folderIdentifier
395 public function getFolderInfoByIdentifier($folderIdentifier);
398 * Returns a list of files inside the specified path
400 * @param string $folderIdentifier
402 * @param int $numberOfItems
403 * @param bool $recursive
404 * @param array $filenameFilterCallbacks callbacks for filtering the items
405 * @param string $sort Property name used to sort the items.
406 * Among them may be: '' (empty, no sorting), name,
407 * fileext, size, tstamp and rw.
408 * If a driver does not support the given property, it
409 * should fall back to "name".
410 * @param bool $sortRev TRUE to indicate reverse sorting (last to first)
411 * @return array of FileIdentifiers
413 public function getFilesInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = FALSE, array $filenameFilterCallbacks = array(), $sort = '', $sortRev = FALSE);
416 * Returns a list of folders inside the specified path
418 * @param string $folderIdentifier
420 * @param int $numberOfItems
421 * @param bool $recursive
422 * @param array $folderNameFilterCallbacks callbacks for filtering the items
423 * @param string $sort Property name used to sort the items.
424 * Among them may be: '' (empty, no sorting), name,
425 * fileext, size, tstamp and rw.
426 * If a driver does not support the given property, it
427 * should fall back to "name".
428 * @param bool $sortRev TRUE to indicate reverse sorting (last to first)
429 * @return array of Folder Identifier
431 public function getFoldersInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = FALSE, array $folderNameFilterCallbacks = array(), $sort = '', $sortRev = FALSE);
434 * Returns the number of files inside the specified path
436 * @param string $folderIdentifier
437 * @param bool $recursive
438 * @param array $filenameFilterCallbacks callbacks for filtering the items
439 * @return integer Number of files in folder
441 public function countFilesInFolder($folderIdentifier, $recursive = FALSE, array $filenameFilterCallbacks = array());
444 * Returns the number of folders inside the specified path
446 * @param string $folderIdentifier
447 * @param bool $recursive
448 * @param array $folderNameFilterCallbacks callbacks for filtering the items
449 * @return integer Number of folders in folder
451 public function countFoldersInFolder($folderIdentifier, $recursive = FALSE, array $folderNameFilterCallbacks = array());