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