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