[BUGFIX] Improve method annotation and type hinting in FAL
[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 * @return array
380 */
381 abstract public function getFileInfoByIdentifier($identifier);
382
383 /**
384 * Returns information about a file for a given file object.
385 *
386 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
387 * @return array
388 */
389 public function getFileInfo(\TYPO3\CMS\Core\Resource\FileInterface $file) {
390 return $this->getFileInfoByIdentifier($file->getIdentifier());
391 }
392
393 /**
394 * Returns a file object by its identifier.
395 *
396 * @param string $identifier
397 * @return \TYPO3\CMS\Core\Resource\FileInterface
398 */
399 public function getFile($identifier) {
400 $fileObject = NULL;
401 if (!$this->fileExists($identifier)) {
402 throw new \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException();
403 }
404 $fileInfo = $this->getFileInfoByIdentifier($identifier);
405 $fileObject = $this->getFileObject($fileInfo);
406 return $fileObject;
407 }
408
409 /**
410 * Creates a file object from a given file data array
411 *
412 * @param array $fileData
413 * @return \TYPO3\CMS\Core\Resource\File
414 */
415 protected function getFileObject(array $fileData) {
416 $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->createFileObject($fileData);
417 return $fileObject;
418 }
419
420 /**
421 * Returns a folder by its identifier.
422 *
423 * @param string $identifier
424 * @return \TYPO3\CMS\Core\Resource\Folder
425 */
426 public function getFolder($identifier) {
427 $name = $this->getNameFromIdentifier($identifier);
428 return \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->createFolderObject($this->storage, $identifier, $name);
429 }
430
431 /**
432 * Returns a folder within the given folder. Use this method instead of doing your own string manipulation magic
433 * on the identifiers because non-hierarchical storages might fail otherwise.
434 *
435 * @param $name
436 * @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
437 * @return \TYPO3\CMS\Core\Resource\Folder
438 */
439 abstract public function getFolderInFolder($name, \TYPO3\CMS\Core\Resource\Folder $parentFolder);
440
441 /**
442 * 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
443 * directory listings.
444 *
445 * @param array $filterMethods The filter methods to use
446 * @param string $itemName
447 * @param string $itemIdentifier
448 * @param string $parentIdentifier
449 * @param array $additionalInformation Additional information about the inspected item
450 * @return boolean
451 */
452 protected function applyFilterMethodsToDirectoryItem(array $filterMethods, $itemName, $itemIdentifier, $parentIdentifier, array $additionalInformation = array()) {
453 foreach ($filterMethods as $filter) {
454 if (is_array($filter)) {
455 $result = call_user_func($filter, $itemName, $itemIdentifier, $parentIdentifier, $additionalInformation, $this);
456 // We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
457 // If calling the method succeeded and thus we can't use that as a return value.
458 if ($result === -1) {
459 return FALSE;
460 } elseif ($result === FALSE) {
461 throw new \RuntimeException('Could not apply file/folder name filter ' . $filter[0] . '::' . $filter[1]);
462 }
463 }
464 }
465 return TRUE;
466 }
467
468 /**
469 * Returns a list of files inside the specified path
470 *
471 * @param string $path
472 * @param integer $start The position to start the listing; if not set, start from the beginning
473 * @param integer $numberOfItems The number of items to list; if not set, return all items
474 * @param array $filenameFilterCallbacks The method callbacks to use for filtering the items
475 * @param array $fileData Two-dimensional, identifier-indexed array of file index records from the database
476 * @param boolean $recursive
477 * @return array
478 */
479 // TODO add unit tests
480 public function getFileList($path, $start = 0, $numberOfItems = 0, array $filenameFilterCallbacks = array(), $fileData = array(), $recursive = FALSE) {
481 return $this->getDirectoryItemList($path, $start, $numberOfItems, $filenameFilterCallbacks, $this->fileListCallbackMethod, $fileData, $recursive);
482 }
483
484 /**
485 * Copies a file to a temporary path and returns that path.
486 *
487 * @abstract
488 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
489 * @return string The temporary path
490 */
491 abstract public function copyFileToTemporaryPath(\TYPO3\CMS\Core\Resource\FileInterface $file);
492
493 /**
494 * Moves a file *within* the current storage.
495 * Note that this is only about an intra-storage move action, where a file is just
496 * moved to another folder in the same storage.
497 *
498 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
499 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
500 * @param string $fileName
501 * @return string The new identifier of the file
502 */
503 abstract public function moveFileWithinStorage(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName);
504
505 /**
506 * Copies a file *within* the current storage.
507 * Note that this is only about an intra-storage copy action, where a file is just
508 * copied to another folder in the same storage.
509 *
510 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
511 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
512 * @param string $fileName
513 * @return \TYPO3\CMS\Core\Resource\FileInterface The new (copied) file object.
514 */
515 abstract public function copyFileWithinStorage(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $fileName);
516
517 /**
518 * Folder equivalent to moveFileWithinStorage().
519 *
520 * @param \TYPO3\CMS\Core\Resource\Folder $folderToMove
521 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
522 * @param string $newFolderName
523 * @return array A map of old to new file identifiers
524 */
525 abstract public function moveFolderWithinStorage(\TYPO3\CMS\Core\Resource\Folder $folderToMove, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $newFolderName);
526
527 /**
528 * Folder equivalent to copyFileWithinStorage().
529 *
530 * @param \TYPO3\CMS\Core\Resource\Folder $folderToCopy
531 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
532 * @param string $newFileName
533 * @return boolean
534 */
535 abstract public function copyFolderWithinStorage(\TYPO3\CMS\Core\Resource\Folder $folderToCopy, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $newFileName);
536
537 /**
538 * Move a folder from another storage.
539 *
540 * @param \TYPO3\CMS\Core\Resource\Folder $folderToMove
541 * @param \TYPO3\CMS\Core\Resource\Folder $targetParentFolder
542 * @param string $newFolderName
543 * @throws \BadMethodCallException
544 * @return boolean
545 */
546 public function moveFolderBetweenStorages(\TYPO3\CMS\Core\Resource\Folder $folderToMove, \TYPO3\CMS\Core\Resource\Folder $targetParentFolder, $newFolderName) {
547 // This is not implemented for now as moving files between storages might cause quite some headaches when
548 // something goes wrong. It is also not that common of a use case, so it does not hurt that much to leave it out
549 // for now.
550 throw new \BadMethodCallException('Moving folders between storages is not implemented.');
551 }
552
553 /**
554 * Copy a folder from another storage.
555 *
556 * @param \TYPO3\CMS\Core\Resource\Folder $folderToCopy
557 * @param \TYPO3\CMS\Core\Resource\Folder $targetParentFolder
558 * @param string $newFolderName
559 * @throws \BadMethodCallException
560 * @return boolean
561 */
562 public function copyFolderBetweenStorages(\TYPO3\CMS\Core\Resource\Folder $folderToCopy, \TYPO3\CMS\Core\Resource\Folder $targetParentFolder, $newFolderName) {
563 throw new \BadMethodCallException('Not yet implemented!', 1330262731);
564 }
565
566 /**
567 * Removes a file from this storage. This does not check if the file is
568 * still used or if it is a bad idea to delete it for some other reason
569 * this has to be taken care of in the upper layers (e.g. the Storage)!
570 *
571 * @abstract
572 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
573 * @return boolean TRUE if deleting the file succeeded
574 */
575 abstract public function deleteFile(\TYPO3\CMS\Core\Resource\FileInterface $file);
576
577 /**
578 * Removes a folder from this storage.
579 *
580 * @param \TYPO3\CMS\Core\Resource\Folder $folder
581 * @param boolean $deleteRecursively
582 * @return boolean
583 */
584 abstract public function deleteFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $deleteRecursively = FALSE);
585
586 /**
587 * Adds a file at the specified location. This should only be used internally.
588 *
589 * @abstract
590 * @param string $localFilePath
591 * @param \TYPO3\CMS\Core\Resource\Folder $targetFolder
592 * @param string $targetFileName
593 * @return string The new identifier of the file
594 */
595 // TODO check if this is still necessary if we move more logic to the storage
596 abstract public function addFileRaw($localFilePath, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $targetFileName);
597
598 /**
599 * Deletes a file without access and usage checks.
600 * This should only be used internally.
601 *
602 * This accepts an identifier instead of an object because we might want to
603 * delete files that have no object associated with (or we don't want to
604 * create an object for) them - e.g. when moving a file to another storage.
605 *
606 * @abstract
607 * @param string $identifier
608 * @return boolean TRUE if removing the file succeeded
609 */
610 abstract public function deleteFileRaw($identifier);
611
612 /*******************
613 * FOLDER FUNCTIONS
614 *******************/
615 /**
616 * Returns the root level folder of the storage.
617 *
618 * @abstract
619 * @return \TYPO3\CMS\Core\Resource\Folder
620 */
621 abstract public function getRootLevelFolder();
622
623 /**
624 * Returns the default folder new files should be put into.
625 *
626 * @abstract
627 * @return \TYPO3\CMS\Core\Resource\Folder
628 */
629 abstract public function getDefaultFolder();
630
631 /**
632 * Creates a folder.
633 *
634 * @param string $newFolderName
635 * @param \TYPO3\CMS\Core\Resource\Folder $parentFolder
636 * @return \TYPO3\CMS\Core\Resource\Folder The new (created) folder object
637 */
638 abstract public function createFolder($newFolderName, \TYPO3\CMS\Core\Resource\Folder $parentFolder);
639
640 /**
641 * Returns a list of all folders in a given path
642 *
643 * @param string $path
644 * @param integer $start The position to start the listing; if not set, start from the beginning
645 * @param integer $numberOfItems The number of items to list; if not set, return all items
646 * @param array $foldernameFilterCallbacks The method callbacks to use for filtering the items
647 * @param boolean $recursive
648 * @return array
649 */
650 public function getFolderList($path, $start = 0, $numberOfItems = 0, array $foldernameFilterCallbacks = array(), $recursive = FALSE) {
651 return $this->getDirectoryItemList($path, $start, $numberOfItems, $foldernameFilterCallbacks, $this->folderListCallbackMethod, $recursive);
652 }
653
654 /**
655 * Checks if a folder exists
656 *
657 * @abstract
658 * @param string $identifier
659 * @return boolean
660 */
661 abstract public function folderExists($identifier);
662
663 /**
664 * Checks if a file inside a storage folder exists.
665 *
666 * @abstract
667 * @param string $folderName
668 * @param \TYPO3\CMS\Core\Resource\Folder $folder
669 * @return boolean
670 */
671 abstract public function folderExistsInFolder($folderName, \TYPO3\CMS\Core\Resource\Folder $folder);
672
673 /**
674 * Renames a folder in this storage.
675 *
676 * @param \TYPO3\CMS\Core\Resource\Folder $folder
677 * @param string $newName The target path (including the file name!)
678 * @return array A map of old to new file identifiers
679 * @throws \RuntimeException if renaming the folder failed
680 */
681 abstract public function renameFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $newName);
682
683 /**
684 * Checks if a given object or identifier is within a container, e.g. if
685 * a file or folder is within another folder.
686 * This can e.g. be used to check for webmounts.
687 *
688 * @abstract
689 * @param \TYPO3\CMS\Core\Resource\Folder $container
690 * @param mixed $content An object or an identifier to check
691 * @return boolean TRUE if $content is within $container
692 */
693 abstract public function isWithin(\TYPO3\CMS\Core\Resource\Folder $container, $content);
694
695 /**
696 * Checks if a folder contains files and (if supported) other folders.
697 *
698 * @param \TYPO3\CMS\Core\Resource\Folder $folder
699 * @return boolean TRUE if there are no files and folders within $folder
700 */
701 abstract public function isFolderEmpty(\TYPO3\CMS\Core\Resource\Folder $folder);
702
703 }
704
705
706 ?>