[BUGFIX] Clean-up responsibilities of FAL classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / Driver / AbstractDriver.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Driver;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Ingmar Schlecht <ingmar.schlecht@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Core\Utility\PathUtility;
31
32 /**
33 * An abstract implementation of a storage driver.
34 *
35 * @author Ingmar Schlecht <ingmar.schlecht@typo3.org>
36 * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
37 */
38 abstract class AbstractDriver {
39
40 /**
41 * The mount object this driver instance belongs to
42 *
43 * @var \TYPO3\CMS\Core\Resource\ResourceStorage
44 */
45 protected $storage;
46
47 /**
48 * A list of all supported hash algorithms, written all lower case and
49 * without any dashes etc. (e.g. sha1 instead of SHA-1)
50 * Be sure to set this in inherited classes!
51 *
52 * @var array
53 */
54 protected $supportedHashAlgorithms = array();
55
56 /**
57 * The storage folder that forms the root of this FS tree
58 *
59 * @var \TYPO3\CMS\Core\Resource\Folder
60 */
61 protected $rootLevelFolder;
62
63 /**
64 * The default folder new files should be put into.
65 *
66 * @var \TYPO3\CMS\Core\Resource\Folder
67 */
68 protected $defaultLevelFolder;
69
70 /**
71 * The configuration of this driver
72 *
73 * @var array
74 */
75 protected $configuration = array();
76
77 /**
78 * The callback method to handle the files when listing folder contents
79 *
80 * @var string
81 */
82 protected $fileListCallbackMethod = 'getFileList_itemCallback';
83
84 /**
85 * The callback method to handle the folders when listing folder contents
86 *
87 * @var string
88 */
89 protected $folderListCallbackMethod = 'getFolderList_itemCallback';
90
91 /**
92 * Creates this object.
93 *
94 * @param array $configuration
95 */
96 public function __construct(array $configuration = array()) {
97 $this->configuration = $configuration;
98 }
99
100 /**
101 * Initializes this object. This is called by the storage after the driver
102 * has been attached.
103 *
104 * @return void
105 */
106 abstract public function initialize();
107
108 /**
109 * Checks a fileName for validity. This could be overriden in concrete
110 * drivers if they have different file naming rules.
111 *
112 * @param string $fileName
113 * @return boolean TRUE if file name is valid
114 */
115 public function isValidFilename($fileName) {
116 if (strpos($fileName, '/') !== FALSE) {
117 return FALSE;
118 }
119 if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
120 return FALSE;
121 }
122 return TRUE;
123 }
124
125 /**
126 * Sets the storage object that works with this driver
127 *
128 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
129 * @return \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
130 */
131 public function setStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storage) {
132 $this->storage = $storage;
133 return $this;
134 }
135
136 /**
137 * Checks if a configuration is valid for this driver.
138 * Throws an exception if a configuration will not work.
139 *
140 * @abstract
141 * @param array $configuration
142 * @return void
143 */
144 static abstract public function verifyConfiguration(array $configuration);
145
146 /**
147 * processes the configuration, should be overridden by subclasses
148 *
149 * @return void
150 */
151 abstract public function processConfiguration();
152
153 /**
154 * Returns the name of a file/folder based on its identifier.
155 *
156 * @param string $identifier
157 * @return string
158 */
159 protected function getNameFromIdentifier($identifier) {
160 return PathUtility::basename($identifier);
161 }
162
163 /**
164 * Generic handler method for directory listings - gluing together the
165 * listing items is done
166 *
167 * @param string $basePath
168 * @param integer $start
169 * @param integer $numberOfItems
170 * @param array $filterMethods The filter methods used to filter the directory items
171 * @param string $itemHandlerMethod
172 * @param array $itemRows
173 * @param boolean $recursive
174 * @return array
175 */
176 protected function getDirectoryItemList($basePath, $start, $numberOfItems, array $filterMethods, $itemHandlerMethod, $itemRows = array(), $recursive = FALSE) {
177
178 }
179
180 /*******************
181 * CAPABILITIES
182 *******************/
183 /**
184 * The capabilities of this driver. See Storage::CAPABILITY_* constants for possible values. This value should be set
185 * in the constructor of derived classes.
186 *
187 * @var integer
188 */
189 protected $capabilities = 0;
190
191 /**
192 * Returns the capabilities of this driver.
193 *
194 * @return integer
195 * @see Storage::CAPABILITY_* constants
196 */
197 public function getCapabilities() {
198 return $this->capabilities;
199 }
200
201 /**
202 * Returns TRUE if this driver has the given capability.
203 *
204 * @param integer $capability A capability, as defined in a CAPABILITY_* constant
205 * @return boolean
206 */
207 public function hasCapability($capability) {
208 return $this->capabilities & $capability == $capability;
209 }
210
211 /*******************
212 * FILE FUNCTIONS
213 *******************/
214 /**
215 * Returns a temporary path for a given file, including the file extension.
216 *
217 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
218 * @return string
219 */
220 protected function getTemporaryPathForFile(\TYPO3\CMS\Core\Resource\FileInterface $file) {
221 return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-') . '.' . $file->getExtension();
222 }
223
224 /**
225 * Returns the public URL to a file.
226 *
227 * @abstract
228 * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource
229 * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
230 * @return string
231 */
232 abstract public function getPublicUrl(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $relativeToCurrentScript = FALSE);
233
234 /**
235 * Returns a list of all hashing algorithms this Storage supports.
236 *
237 * @return array
238 */
239 public function getSupportedHashAlgorithms() {
240 return $this->supportedHashAlgorithms;
241 }
242
243 /**
244 * Creates a (cryptographic) hash for a file.
245 *
246 * @abstract
247 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
248 * @param string $hashAlgorithm The hash algorithm to use
249 * @return string
250 */
251 abstract public function hash(\TYPO3\CMS\Core\Resource\FileInterface $file, $hashAlgorithm);
252
253 /**
254 * Creates a new file and returns the matching file object for it.
255 *
256 * @abstract
257 * @param string $fileName
258 * @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
259 * @return \TYPO3\CMS\Core\Resource\File
260 */
261 abstract public function createFile($fileName, \TYPO3\CMS\Core\Resource\Folder $parentFolder);
262
263 /**
264 * Returns the contents of a file. Beware that this requires to load the
265 * complete file into memory and also may require fetching the file from an
266 * external location. So this might be an expensive operation (both in terms
267 * of processing resources and money) for large files.
268 *
269 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
270 * @return string The file contents
271 */
272 abstract public function getFileContents(\TYPO3\CMS\Core\Resource\FileInterface $file);
273
274 /**
275 * Sets the contents of a file to the specified value.
276 *
277 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
278 * @param string $contents
279 * @return integer The number of bytes written to the file
280 * @throws \RuntimeException if the operation failed
281 */
282 abstract public function setFileContents(\TYPO3\CMS\Core\Resource\FileInterface $file, $contents);
283
284 /**
285 * Adds a file from the local server hard disk to a given path in TYPO3s virtual file system.
286 *
287 * This assumes that the local file exists, so no further check is done here!
288 *
289 * @param string $localFilePath
290 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
291 * @param string $fileName The name to add the file under
292 * @param \TYPO3\CMS\Core\Resource\AbstractFile $updateFileObject Optional file object to update (instead of creating a new object). With this parameter, this function can be used to "populate" a dummy file object with a real file underneath.
293 * @return \TYPO3\CMS\Core\Resource\FileInterface
294 */
295 abstract public function addFile($localFilePath, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName, \TYPO3\CMS\Core\Resource\AbstractFile $updateFileObject = NULL);
296
297 /**
298 * Checks if a resource exists - does not care for the type (file or folder).
299 *
300 * @param $identifier
301 * @return boolean
302 */
303 abstract public function resourceExists($identifier);
304
305 /**
306 * Checks if a file exists.
307 *
308 * @abstract
309 * @param string $identifier
310 * @return boolean
311 */
312 abstract public function fileExists($identifier);
313
314 /**
315 * Checks if a file inside a storage folder exists.
316 *
317 * @abstract
318 * @param string $fileName
319 * @param \TYPO3\CMS\Core\Resource\Folder $folder
320 * @return boolean
321 */
322 abstract public function fileExistsInFolder($fileName, \TYPO3\CMS\Core\Resource\Folder $folder);
323
324 /**
325 * Returns a (local copy of) a file for processing it. When changing the
326 * file, you have to take care of replacing the current version yourself!
327 *
328 * @abstract
329 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
330 * @param bool $writable Set this to FALSE if you only need the file for read operations. This might speed up things, e.g. by using a cached local version. Never modify the file if you have set this flag!
331 * @return string The path to the file on the local disk
332 */
333 // TODO decide if this should return a file handle object
334 abstract public function getFileForLocalProcessing(\TYPO3\CMS\Core\Resource\FileInterface $file, $writable = TRUE);
335
336 /**
337 * Returns the permissions of a file as an array (keys r, w) of boolean flags
338 *
339 * @abstract
340 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
341 * @return array
342 */
343 abstract public function getFilePermissions(\TYPO3\CMS\Core\Resource\FileInterface $file);
344
345 /**
346 * Returns the permissions of a folder as an array (keys r, w) of boolean flags
347 *
348 * @abstract
349 * @param \TYPO3\CMS\Core\Resource\Folder $folder
350 * @return array
351 */
352 abstract public function getFolderPermissions(\TYPO3\CMS\Core\Resource\Folder $folder);
353
354 /**
355 * Renames a file
356 *
357 * @abstract
358 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
359 * @param string $newName
360 * @return string The new identifier of the file if the operation succeeds
361 * @throws \RuntimeException if renaming the file failed
362 */
363 abstract public function renameFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $newName);
364
365 /**
366 * Replaces the contents (and file-specific metadata) of a file object with a local file.
367 *
368 * @abstract
369 * @param \TYPO3\CMS\Core\Resource\AbstractFile $file
370 * @param string $localFilePath
371 * @return boolean
372 */
373 abstract public function replaceFile(\TYPO3\CMS\Core\Resource\AbstractFile $file, $localFilePath);
374
375 /**
376 * Returns information about a file for a given file identifier.
377 *
378 * @param string $identifier The (relative) path to the file.
379 * @param array $propertiesToExtract Array of properties which should be extracted, if empty all will be extracted
380 * @return array
381 */
382 abstract public function getFileInfoByIdentifier($identifier, array $propertiesToExtract = array());
383
384 /**
385 * Basic implementation of the method that does directly return the
386 * file name as is.
387 *
388 * @param string $fileName Input string, typically the body of a fileName
389 * @param string $charset Charset of the a fileName (defaults to current charset; depending on context)
390 * @return string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed
391 */
392 public function sanitizeFileName($fileName, $charset = '') {
393 return $fileName;
394 }
395
396 /**
397 * Returns information about a file for a given file object.
398 *
399 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
400 * @param array $propertiesToExtract Array of properties which should be extracted, if empty all will be extracted
401 * @return array
402 */
403 public function getFileInfo(\TYPO3\CMS\Core\Resource\FileInterface $file, array $propertiesToExtract = array()) {
404 return $this->getFileInfoByIdentifier($file->getIdentifier(), $propertiesToExtract);
405 }
406
407 /**
408 * Returns a file object by its identifier.
409 *
410 * @param string $identifier
411 * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
412 * @return \TYPO3\CMS\Core\Resource\FileInterface
413 */
414 public function getFile($identifier) {
415 $fileObject = NULL;
416 if (!$this->fileExists($identifier)) {
417 throw new \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException();
418 }
419 $fileInfo = $this->getFileInfoByIdentifier($identifier);
420 $fileObject = $this->getFileObject($fileInfo);
421 return $fileObject;
422 }
423
424 /**
425 * Creates a file object from a given file data array
426 *
427 * @param array $fileData
428 * @return \TYPO3\CMS\Core\Resource\File
429 */
430 protected function getFileObject(array $fileData) {
431 $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->createFileObject($fileData, $this->storage);
432 return $fileObject;
433 }
434
435 /**
436 * Returns a folder by its identifier.
437 *
438 * @param string $identifier
439 * @return \TYPO3\CMS\Core\Resource\Folder
440 */
441 public function getFolder($identifier) {
442 $name = $this->getNameFromIdentifier($identifier);
443 return \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->createFolderObject($this->storage, $identifier, $name);
444 }
445
446 /**
447 * Returns a folder within the given folder. Use this method instead of doing your own string manipulation magic
448 * on the identifiers because non-hierarchical storages might fail otherwise.
449 *
450 * @param $name
451 * @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
452 * @return \TYPO3\CMS\Core\Resource\Folder
453 */
454 abstract public function getFolderInFolder($name, \TYPO3\CMS\Core\Resource\Folder $parentFolder);
455
456 /**
457 * Applies a set of filter methods to a file name to find out if it should be used or not. This is e.g. used by
458 * directory listings.
459 *
460 * @param array $filterMethods The filter methods to use
461 * @param string $itemName
462 * @param string $itemIdentifier
463 * @param string $parentIdentifier
464 * @param array $additionalInformation Additional information about the inspected item
465 * @throws \RuntimeException
466 * @return boolean
467 */
468 protected function applyFilterMethodsToDirectoryItem(array $filterMethods, $itemName, $itemIdentifier, $parentIdentifier, array $additionalInformation = array()) {
469 foreach ($filterMethods as $filter) {
470 if (is_array($filter)) {
471 $result = call_user_func($filter, $itemName, $itemIdentifier, $parentIdentifier, $additionalInformation, $this);
472 // We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
473 // If calling the method succeeded and thus we can't use that as a return value.
474 if ($result === -1) {
475 return FALSE;
476 } elseif ($result === FALSE) {
477 throw new \RuntimeException('Could not apply file/folder name filter ' . $filter[0] . '::' . $filter[1]);
478 }
479 }
480 }
481 return TRUE;
482 }
483
484 /**
485 * Returns a list of files inside the specified path
486 *
487 * @param string $path
488 * @param integer $start The position to start the listing; if not set, start from the beginning
489 * @param integer $numberOfItems The number of items to list; if not set, return all items
490 * @param array $filenameFilterCallbacks The method callbacks to use for filtering the items
491 * @param array $fileData Two-dimensional, identifier-indexed array of file index records from the database
492 * @param boolean $recursive
493 * @return array
494 */
495 // TODO add unit tests
496 public function getFileList($path, $start = 0, $numberOfItems = 0, array $filenameFilterCallbacks = array(), $fileData = array(), $recursive = FALSE) {
497 return $this->getDirectoryItemList($path, $start, $numberOfItems, $filenameFilterCallbacks, $this->fileListCallbackMethod, $fileData, $recursive);
498 }
499
500 /**
501 * Copies a file to a temporary path and returns that path.
502 *
503 * @abstract
504 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
505 * @return string The temporary path
506 */
507 abstract public function copyFileToTemporaryPath(\TYPO3\CMS\Core\Resource\FileInterface $file);
508
509 /**
510 * Moves a file *within* the current storage.
511 * Note that this is only about an intra-storage move action, where a file is just
512 * moved to another folder in the same storage.
513 *
514 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
515 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
516 * @param string $fileName
517 * @return string The new identifier of the file
518 */
519 abstract public function moveFileWithinStorage(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName);
520
521 /**
522 * Copies a file *within* the current storage.
523 * Note that this is only about an intra-storage copy action, where a file is just
524 * copied to another folder in the same storage.
525 *
526 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
527 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
528 * @param string $fileName
529 * @return \TYPO3\CMS\Core\Resource\FileInterface The new (copied) file object.
530 */
531 abstract public function copyFileWithinStorage(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName);
532
533 /**
534 * Folder equivalent to moveFileWithinStorage().
535 *
536 * @param \TYPO3\CMS\Core\Resource\Folder $folderToMove
537 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
538 * @param string $newFolderName
539 * @return array A map of old to new file identifiers
540 */
541 abstract public function moveFolderWithinStorage(\TYPO3\CMS\Core\Resource\Folder $folderToMove, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $newFolderName);
542
543 /**
544 * Folder equivalent to copyFileWithinStorage().
545 *
546 * @param \TYPO3\CMS\Core\Resource\Folder $folderToCopy
547 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
548 * @param string $newFileName
549 * @return boolean
550 */
551 abstract public function copyFolderWithinStorage(\TYPO3\CMS\Core\Resource\Folder $folderToCopy, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $newFileName);
552
553 /**
554 * Move a folder from another storage.
555 *
556 * @param \TYPO3\CMS\Core\Resource\Folder $folderToMove
557 * @param \TYPO3\CMS\Core\Resource\Folder $targetParentFolder
558 * @param string $newFolderName
559 * @throws \BadMethodCallException
560 * @return boolean
561 */
562 public function moveFolderBetweenStorages(\TYPO3\CMS\Core\Resource\Folder $folderToMove, \TYPO3\CMS\Core\Resource\Folder $targetParentFolder, $newFolderName) {
563 // This is not implemented for now as moving files between storages might cause quite some headaches when
564 // something goes wrong. It is also not that common of a use case, so it does not hurt that much to leave it out
565 // for now.
566 throw new \BadMethodCallException('Moving folders between storages is not implemented.');
567 }
568
569 /**
570 * Copy a folder from another storage.
571 *
572 * @param \TYPO3\CMS\Core\Resource\Folder $folderToCopy
573 * @param \TYPO3\CMS\Core\Resource\Folder $targetParentFolder
574 * @param string $newFolderName
575 * @throws \BadMethodCallException
576 * @return boolean
577 */
578 public function copyFolderBetweenStorages(\TYPO3\CMS\Core\Resource\Folder $folderToCopy, \TYPO3\CMS\Core\Resource\Folder $targetParentFolder, $newFolderName) {
579 throw new \BadMethodCallException('Not yet implemented!', 1330262731);
580 }
581
582 /**
583 * Removes a file from this storage. This does not check if the file is
584 * still used or if it is a bad idea to delete it for some other reason
585 * this has to be taken care of in the upper layers (e.g. the Storage)!
586 *
587 * @abstract
588 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
589 * @return boolean TRUE if deleting the file succeeded
590 */
591 abstract public function deleteFile(\TYPO3\CMS\Core\Resource\FileInterface $file);
592
593 /**
594 * Removes a folder from this storage.
595 *
596 * @param \TYPO3\CMS\Core\Resource\Folder $folder
597 * @param boolean $deleteRecursively
598 * @return boolean
599 */
600 abstract public function deleteFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $deleteRecursively = FALSE);
601
602 /**
603 * Adds a file at the specified location. This should only be used internally.
604 *
605 * @abstract
606 * @param string $localFilePath
607 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
608 * @param string $targetFileName
609 * @return string The new identifier of the file
610 */
611 // TODO check if this is still necessary if we move more logic to the storage
612 abstract public function addFileRaw($localFilePath, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $targetFileName);
613
614 /**
615 * Deletes a file without access and usage checks.
616 * This should only be used internally.
617 *
618 * This accepts an identifier instead of an object because we might want to
619 * delete files that have no object associated with (or we don't want to
620 * create an object for) them - e.g. when moving a file to another storage.
621 *
622 * @abstract
623 * @param string $identifier
624 * @return boolean TRUE if removing the file succeeded
625 */
626 abstract public function deleteFileRaw($identifier);
627
628 /*******************
629 * FOLDER FUNCTIONS
630 *******************/
631 /**
632 * Returns the root level folder of the storage.
633 *
634 * @abstract
635 * @return \TYPO3\CMS\Core\Resource\Folder
636 */
637 abstract public function getRootLevelFolder();
638
639 /**
640 * Returns the default folder new files should be put into.
641 *
642 * @abstract
643 * @return \TYPO3\CMS\Core\Resource\Folder
644 */
645 abstract public function getDefaultFolder();
646
647 /**
648 * Creates a folder.
649 *
650 * @param string $newFolderName
651 * @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
652 * @return \TYPO3\CMS\Core\Resource\Folder The new (created) folder object
653 */
654 abstract public function createFolder($newFolderName, \TYPO3\CMS\Core\Resource\Folder $parentFolder);
655
656 /**
657 * Returns a list of all folders in a given path
658 *
659 * @param string $path
660 * @param integer $start The position to start the listing; if not set, start from the beginning
661 * @param integer $numberOfItems The number of items to list; if not set, return all items
662 * @param array $foldernameFilterCallbacks The method callbacks to use for filtering the items
663 * @param boolean $recursive
664 * @return array
665 */
666 public function getFolderList($path, $start = 0, $numberOfItems = 0, array $foldernameFilterCallbacks = array(), $recursive = FALSE) {
667 return $this->getDirectoryItemList($path, $start, $numberOfItems, $foldernameFilterCallbacks, $this->folderListCallbackMethod, $recursive);
668 }
669
670 /**
671 * Checks if a folder exists
672 *
673 * @abstract
674 * @param string $identifier
675 * @return boolean
676 */
677 abstract public function folderExists($identifier);
678
679 /**
680 * Checks if a file inside a storage folder exists.
681 *
682 * @abstract
683 * @param string $folderName
684 * @param \TYPO3\CMS\Core\Resource\Folder $folder
685 * @return boolean
686 */
687 abstract public function folderExistsInFolder($folderName, \TYPO3\CMS\Core\Resource\Folder $folder);
688
689 /**
690 * Renames a folder in this storage.
691 *
692 * @param \TYPO3\CMS\Core\Resource\Folder $folder
693 * @param string $newName The target path (including the file name!)
694 * @return array A map of old to new file identifiers
695 * @throws \RuntimeException if renaming the folder failed
696 */
697 abstract public function renameFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $newName);
698
699 /**
700 * Checks if a given object or identifier is within a container, e.g. if
701 * a file or folder is within another folder.
702 * This can e.g. be used to check for webmounts.
703 *
704 * @abstract
705 * @param \TYPO3\CMS\Core\Resource\Folder $container
706 * @param mixed $content An object or an identifier to check
707 * @return boolean TRUE if $content is within $container
708 */
709 abstract public function isWithin(\TYPO3\CMS\Core\Resource\Folder $container, $content);
710
711 /**
712 * Checks if a folder contains files and (if supported) other folders.
713 *
714 * @param \TYPO3\CMS\Core\Resource\Folder $folder
715 * @return boolean TRUE if there are no files and folders within $folder
716 */
717 abstract public function isFolderEmpty(\TYPO3\CMS\Core\Resource\Folder $folder);
718
719 }