‪TYPO3CMS  9.5
LocalDriver.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Psr\Http\Message\ResponseInterface;
28 
33 {
37  const ‪UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\\x00-\\x2C\\/\\x3A-\\x3F\\x5B-\\x60\\x7B-\\xBF';
38 
44  protected ‪$absoluteBasePath;
45 
51  protected ‪$supportedHashAlgorithms = ['sha1', 'md5'];
52 
59  protected ‪$baseUri;
60 
62  protected ‪$mappingFolderNameToRole = [
63  '_recycler_' => ‪FolderInterface::ROLE_RECYCLER,
65  'user_upload' => ‪FolderInterface::ROLE_USERUPLOAD,
66  ];
67 
71  public function ‪__construct(array ‪$configuration = [])
72  {
73  parent::__construct(‪$configuration);
74  // The capabilities default of this driver. See CAPABILITY_* constants for possible values
75  $this->capabilities =
80  }
81 
91  {
92  $this->capabilities &= ‪$capabilities;
93 
95  }
96 
100  public function ‪processConfiguration()
101  {
102  $this->absoluteBasePath = $this->‪calculateBasePath($this->configuration);
103  $this->‪determineBaseUrl();
104  if ($this->baseUri === null) {
105  // remove public flag
106  $this->capabilities &= ~‪ResourceStorage::CAPABILITY_PUBLIC;
107  }
108  }
109 
114  public function ‪initialize()
115  {
116  }
117 
122  protected function ‪determineBaseUrl()
123  {
124  // only calculate baseURI if the storage does not enforce jumpUrl Script
126  if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, ‪Environment::getPublicPath())) {
127  // use site-relative URLs
128  $temporaryBaseUri = rtrim(‪PathUtility::stripPathSitePrefix($this->absoluteBasePath), '/');
129  if ($temporaryBaseUri !== '') {
130  $uriParts = explode('/', $temporaryBaseUri);
131  $uriParts = array_map('rawurlencode', $uriParts);
132  $temporaryBaseUri = implode('/', $uriParts) . '/';
133  }
134  $this->baseUri = $temporaryBaseUri;
135  } elseif (isset($this->configuration['baseUri']) && GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
136  $this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
137  }
138  }
139  }
140 
149  protected function ‪calculateBasePath(array ‪$configuration)
150  {
151  if (!array_key_exists('basePath', ‪$configuration) || empty(‪$configuration['basePath'])) {
152  throw new Exception\InvalidConfigurationException(
153  'Configuration must contain base path.',
154  1346510477
155  );
156  }
157 
158  if (!empty(‪$configuration['pathType']) && ‪$configuration['pathType'] === 'relative') {
159  $relativeBasePath = ‪$configuration['basePath'];
160  ‪$absoluteBasePath = ‪Environment::getPublicPath() . '/' . $relativeBasePath;
161  } else {
163  }
165  ‪$absoluteBasePath = rtrim(‪$absoluteBasePath, '/') . '/';
166  if (!is_dir(‪$absoluteBasePath)) {
167  throw new Exception\InvalidConfigurationException(
168  'Base path "' . ‪$absoluteBasePath . '" does not exist or is no directory.',
169  1299233097
170  );
171  }
172  return ‪$absoluteBasePath;
173  }
174 
183  public function ‪getPublicUrl($identifier)
184  {
185  $publicUrl = null;
186  if ($this->baseUri !== null) {
187  $uriParts = explode('/', ltrim($identifier, '/'));
188  $uriParts = array_map('rawurlencode', $uriParts);
189  $identifier = implode('/', $uriParts);
190  $publicUrl = $this->baseUri . $identifier;
191  }
192  return $publicUrl;
193  }
194 
200  public function ‪getRootLevelFolder()
201  {
202  return '/';
203  }
204 
210  public function ‪getDefaultFolder()
211  {
212  $identifier = '/user_upload/';
213  $createFolder = !$this->‪folderExists($identifier);
214  if ($createFolder === true) {
215  $identifier = $this->‪createFolder('user_upload');
216  }
217  return $identifier;
218  }
219 
229  public function ‪createFolder($newFolderName, $parentFolderIdentifier = '', $recursive = false)
230  {
231  $parentFolderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($parentFolderIdentifier);
232  $newFolderName = trim($newFolderName, '/');
233  if ($recursive === false) {
234  $newFolderName = $this->‪sanitizeFileName($newFolderName);
235  $newIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($parentFolderIdentifier . $newFolderName . '/');
236  GeneralUtility::mkdir($this->‪getAbsolutePath($newIdentifier));
237  } else {
238  $parts = GeneralUtility::trimExplode('/', $newFolderName);
239  $parts = array_map([$this, 'sanitizeFileName'], $parts);
240  $newFolderName = implode('/', $parts);
241  $newIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier(
242  $parentFolderIdentifier . $newFolderName . '/'
243  );
244  GeneralUtility::mkdir_deep($this->‪getAbsolutePath($newIdentifier));
245  }
246  return $newIdentifier;
247  }
248 
257  public function ‪getFileInfoByIdentifier($fileIdentifier, array $propertiesToExtract = [])
258  {
259  $absoluteFilePath = $this->‪getAbsolutePath($fileIdentifier);
260  // don't use $this->fileExists() because we need the absolute path to the file anyways, so we can directly
261  // use PHP's filesystem method.
262  if (!file_exists($absoluteFilePath) || !is_file($absoluteFilePath)) {
263  throw new \InvalidArgumentException('File ' . $fileIdentifier . ' does not exist.', 1314516809);
264  }
265 
266  $dirPath = ‪PathUtility::dirname($fileIdentifier);
267  $dirPath = $this->‪canonicalizeAndCheckFolderIdentifier($dirPath);
268  return $this->‪extractFileInformation($absoluteFilePath, $dirPath, $propertiesToExtract);
269  }
270 
278  public function ‪getFolderInfoByIdentifier($folderIdentifier)
279  {
280  $folderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
281 
282  if (!$this->‪folderExists($folderIdentifier)) {
283  throw new Exception\FolderDoesNotExistException(
284  'Folder "' . $folderIdentifier . '" does not exist.',
285  1314516810
286  );
287  }
288  $absolutePath = $this->‪getAbsolutePath($folderIdentifier);
289  return [
290  'identifier' => $folderIdentifier,
291  'name' => ‪PathUtility::basename($folderIdentifier),
292  'mtime' => filemtime($absolutePath),
293  'ctime' => filectime($absolutePath),
294  'storage' => ‪$this->storageUid
295  ];
296  }
297 
310  public function ‪sanitizeFileName($fileName, $charset = 'utf-8')
311  {
312  // Handle UTF-8 characters
313  if (‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
314  // Allow ".", "-", 0-9, a-z, A-Z and everything beyond U+C0 (latin capital letter a with grave)
315  $cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . ']/u', '_', trim($fileName));
316  } else {
317  $fileName = GeneralUtility::makeInstance(CharsetConverter::class)->specCharsToASCII($charset, $fileName);
318  // Replace unwanted characters with underscores
319  $cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . '\\xC0-\\xFF]/', '_', trim($fileName));
320  }
321  // Strip trailing dots and return
322  $cleanFileName = rtrim($cleanFileName, '.');
323  if ($cleanFileName === '') {
324  throw new Exception\InvalidFileNameException(
325  'File name ' . $fileName . ' is invalid.',
326  1320288991
327  );
328  }
329  return $cleanFileName;
330  }
331 
351  protected function ‪getDirectoryItemList($folderIdentifier, $start = 0, $numberOfItems = 0, array $filterMethods, $includeFiles = true, $includeDirs = true, $recursive = false, $sort = '', $sortRev = false)
352  {
353  $folderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
354  $realPath = $this->‪getAbsolutePath($folderIdentifier);
355  if (!is_dir($realPath)) {
356  throw new \InvalidArgumentException(
357  'Cannot list items in directory ' . $folderIdentifier . ' - does not exist or is no directory',
358  1314349666
359  );
360  }
361 
362  $items = $this->‪retrieveFileAndFoldersInPath($realPath, $recursive, $includeFiles, $includeDirs, $sort, $sortRev);
363  $iterator = new \ArrayIterator($items);
364  if ($iterator->count() === 0) {
365  return [];
366  }
367 
368  // $c is the counter for how many items we still have to fetch (-1 is unlimited)
369  $c = $numberOfItems > 0 ? $numberOfItems : - 1;
370  $items = [];
371  while ($iterator->valid() && ($numberOfItems === 0 || $c > 0)) {
372  // $iteratorItem is the file or folder name
373  $iteratorItem = $iterator->current();
374  // go on to the next iterator item now as we might skip this one early
375  $iterator->next();
376 
377  try {
378  if (
380  $filterMethods,
381  $iteratorItem['name'],
382  $iteratorItem['identifier'],
383  $this->‪getParentFolderIdentifierOfIdentifier($iteratorItem['identifier'])
384  )
385  ) {
386  continue;
387  }
388  if ($start > 0) {
389  $start--;
390  } else {
391  $items[$iteratorItem['identifier']] = $iteratorItem['identifier'];
392  // Decrement item counter to make sure we only return $numberOfItems
393  // we cannot do this earlier in the method (unlike moving the iterator forward) because we only add the
394  // item here
395  --$c;
396  }
397  } catch (Exception\InvalidPathException $e) {
398  }
399  }
400  return $items;
401  }
402 
414  protected function ‪applyFilterMethodsToDirectoryItem(array $filterMethods, $itemName, $itemIdentifier, $parentIdentifier)
415  {
416  foreach ($filterMethods as $filter) {
417  if (is_callable($filter)) {
418  $result = call_user_func($filter, $itemName, $itemIdentifier, $parentIdentifier, [], $this);
419  // We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
420  // If calling the method succeeded and thus we can't use that as a return value.
421  if ($result === -1) {
422  return false;
423  }
424  if ($result === false) {
425  throw new \RuntimeException(
426  'Could not apply file/folder name filter ' . $filter[0] . '::' . $filter[1],
427  1476046425
428  );
429  }
430  }
431  }
432  return true;
433  }
434 
442  public function ‪getFileInFolder($fileName, $folderIdentifier)
443  {
444  return $this->‪canonicalizeAndCheckFileIdentifier($folderIdentifier . '/' . $fileName);
445  }
446 
463  public function ‪getFilesInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $filenameFilterCallbacks = [], $sort = '', $sortRev = false)
464  {
465  return $this->‪getDirectoryItemList($folderIdentifier, $start, $numberOfItems, $filenameFilterCallbacks, true, false, $recursive, $sort, $sortRev);
466  }
467 
476  public function ‪countFilesInFolder($folderIdentifier, $recursive = false, array $filenameFilterCallbacks = [])
477  {
478  return count($this->‪getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filenameFilterCallbacks));
479  }
480 
497  public function ‪getFoldersInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $folderNameFilterCallbacks = [], $sort = '', $sortRev = false)
498  {
499  return $this->‪getDirectoryItemList($folderIdentifier, $start, $numberOfItems, $folderNameFilterCallbacks, false, true, $recursive, $sort, $sortRev);
500  }
501 
510  public function ‪countFoldersInFolder($folderIdentifier, $recursive = false, array $folderNameFilterCallbacks = [])
511  {
512  return count($this->‪getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $folderNameFilterCallbacks));
513  }
514 
530  protected function ‪retrieveFileAndFoldersInPath($path, $recursive = false, $includeFiles = true, $includeDirs = true, $sort = '', $sortRev = false)
531  {
532  $pathLength = strlen($this->‪getAbsoluteBasePath());
533  $iteratorMode = \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::FOLLOW_SYMLINKS;
534  if ($recursive) {
535  $iterator = new \RecursiveIteratorIterator(
536  new \RecursiveDirectoryIterator($path, $iteratorMode),
537  \RecursiveIteratorIterator::SELF_FIRST,
538  \RecursiveIteratorIterator::CATCH_GET_CHILD
539  );
540  } else {
541  $iterator = new \RecursiveDirectoryIterator($path, $iteratorMode);
542  }
543 
544  $directoryEntries = [];
545  while ($iterator->valid()) {
547  $entry = $iterator->current();
548  $isFile = $entry->isFile();
549  $isDirectory = $isFile ? false : $entry->isDir();
550  if (
551  (!$isFile && !$isDirectory) // skip non-files/non-folders
552  || ($isFile && !$includeFiles) // skip files if they are excluded
553  || ($isDirectory && !$includeDirs) // skip directories if they are excluded
554  || $entry->getFilename() === '' // skip empty entries
555  || !$entry->isReadable() // skip unreadable entries
556  ) {
557  $iterator->next();
558  continue;
559  }
560  $entryIdentifier = '/' . substr($entry->getPathname(), $pathLength);
561  $entryName = ‪PathUtility::basename($entryIdentifier);
562  if ($isDirectory) {
563  $entryIdentifier .= '/';
564  }
565  $entryArray = [
566  'identifier' => $entryIdentifier,
567  'name' => $entryName,
568  'type' => $isDirectory ? 'dir' : 'file'
569  ];
570  $directoryEntries[$entryIdentifier] = $entryArray;
571  $iterator->next();
572  }
573  return $this->‪sortDirectoryEntries($directoryEntries, $sort, $sortRev);
574  }
575 
589  protected function ‪sortDirectoryEntries($directoryEntries, $sort = '', $sortRev = false)
590  {
591  $entriesToSort = [];
592  foreach ($directoryEntries as $entryArray) {
593  ‪$dir = pathinfo($entryArray['name'], PATHINFO_DIRNAME) . '/';
594  $fullPath = $this->‪getAbsoluteBasePath() . $entryArray['identifier'];
595  switch ($sort) {
596  case 'size':
597  $sortingKey = '0';
598  if ($entryArray['type'] === 'file') {
599  $sortingKey = $this->‪getSpecificFileInformation($fullPath, ‪$dir, 'size');
600  }
601  // Add a character for a natural order sorting
602  $sortingKey .= 's';
603  break;
604  case 'rw':
605  $perms = $this->‪getPermissions($entryArray['identifier']);
606  $sortingKey = ($perms['r'] ? 'R' : '')
607  . ($perms['w'] ? 'W' : '');
608  break;
609  case 'fileext':
610  $sortingKey = pathinfo($entryArray['name'], PATHINFO_EXTENSION);
611  break;
612  case 'tstamp':
613  $sortingKey = $this->‪getSpecificFileInformation($fullPath, ‪$dir, 'mtime');
614  // Add a character for a natural order sorting
615  $sortingKey .= 't';
616  break;
617  case 'name':
618  case 'file':
619  default:
620  $sortingKey = $entryArray['name'];
621  }
622  $i = 0;
623  while (isset($entriesToSort[$sortingKey . $i])) {
624  $i++;
625  }
626  $entriesToSort[$sortingKey . $i] = $entryArray;
627  }
628  uksort($entriesToSort, 'strnatcasecmp');
629 
630  if ($sortRev) {
631  $entriesToSort = array_reverse($entriesToSort);
632  }
633 
634  return $entriesToSort;
635  }
636 
645  protected function ‪extractFileInformation($filePath, $containerPath, array $propertiesToExtract = [])
646  {
647  if (empty($propertiesToExtract)) {
648  $propertiesToExtract = [
649  'size', 'atime', 'mtime', 'ctime', 'mimetype', 'name', 'extension',
650  'identifier', 'identifier_hash', 'storage', 'folder_hash'
651  ];
652  }
653  $fileInformation = [];
654  foreach ($propertiesToExtract as $property) {
655  $fileInformation[$property] = $this->‪getSpecificFileInformation($filePath, $containerPath, $property);
656  }
657  return $fileInformation;
658  }
659 
670  public function ‪getSpecificFileInformation($fileIdentifier, $containerPath, $property)
671  {
672  $identifier = $this->‪canonicalizeAndCheckFileIdentifier($containerPath . ‪PathUtility::basename($fileIdentifier));
673 
675  $fileInfo = GeneralUtility::makeInstance(FileInfo::class, $fileIdentifier);
676  switch ($property) {
677  case 'size':
678  return $fileInfo->getSize();
679  case 'atime':
680  return $fileInfo->getATime();
681  case 'mtime':
682  return $fileInfo->getMTime();
683  case 'ctime':
684  return $fileInfo->getCTime();
685  case 'name':
686  return ‪PathUtility::basename($fileIdentifier);
687  case 'extension':
688  return ‪PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION);
689  case 'mimetype':
690  return (string)$fileInfo->getMimeType();
691  case 'identifier':
692  return $identifier;
693  case 'storage':
694  return ‪$this->storageUid;
695  case 'identifier_hash':
696  return $this->‪hashIdentifier($identifier);
697  case 'folder_hash':
698  return $this->‪hashIdentifier($this->‪getParentFolderIdentifierOfIdentifier($identifier));
699  default:
700  throw new \InvalidArgumentException(sprintf('The information "%s" is not available.', $property), 1476047422);
701  }
702  }
703 
709  protected function ‪getAbsoluteBasePath()
710  {
712  }
713 
721  protected function ‪getAbsolutePath($fileIdentifier)
722  {
723  $relativeFilePath = ltrim($this->‪canonicalizeAndCheckFileIdentifier($fileIdentifier), '/');
724  $path = $this->absoluteBasePath . $relativeFilePath;
725  return $path;
726  }
727 
737  public function ‪hash($fileIdentifier, $hashAlgorithm)
738  {
739  if (!in_array($hashAlgorithm, $this->supportedHashAlgorithms)) {
740  throw new \InvalidArgumentException('Hash algorithm "' . $hashAlgorithm . '" is not supported.', 1304964032);
741  }
742  switch ($hashAlgorithm) {
743  case 'sha1':
744  $hash = sha1_file($this->‪getAbsolutePath($fileIdentifier));
745  break;
746  case 'md5':
747  $hash = md5_file($this->‪getAbsolutePath($fileIdentifier));
748  break;
749  default:
750  throw new \RuntimeException('Hash algorithm ' . $hashAlgorithm . ' is not implemented.', 1329644451);
751  }
752  return $hash;
753  }
754 
768  public function ‪addFile($localFilePath, $targetFolderIdentifier, $newFileName = '', $removeOriginal = true)
769  {
770  $localFilePath = $this->‪canonicalizeAndCheckFilePath($localFilePath);
771  // as for the "virtual storage" for backwards-compatibility, this check always fails, as the file probably lies under public web path
772  // thus, it is not checked here
773  // @todo is check in storage
774  if (GeneralUtility::isFirstPartOfStr($localFilePath, $this->absoluteBasePath) && $this->storageUid > 0) {
775  throw new \InvalidArgumentException('Cannot add a file that is already part of this storage.', 1314778269);
776  }
777  $newFileName = $this->‪sanitizeFileName($newFileName !== '' ? $newFileName : ‪PathUtility::basename($localFilePath));
778  $newFileIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($targetFolderIdentifier) . $newFileName;
779  $targetPath = $this->‪getAbsolutePath($newFileIdentifier);
780 
781  if ($removeOriginal) {
782  if (is_uploaded_file($localFilePath)) {
783  $result = move_uploaded_file($localFilePath, $targetPath);
784  } else {
785  $result = rename($localFilePath, $targetPath);
786  }
787  } else {
788  $result = copy($localFilePath, $targetPath);
789  }
790  if ($result === false || !file_exists($targetPath)) {
791  throw new \RuntimeException(
792  'Adding file ' . $localFilePath . ' at ' . $newFileIdentifier . ' failed.',
793  1476046453
794  );
795  }
796  clearstatcache();
797  // Change the permissions of the file
798  GeneralUtility::fixPermissions($targetPath);
799  return $newFileIdentifier;
800  }
801 
809  public function ‪fileExists($fileIdentifier)
810  {
811  $absoluteFilePath = $this->‪getAbsolutePath($fileIdentifier);
812  return is_file($absoluteFilePath);
813  }
814 
822  public function ‪fileExistsInFolder($fileName, $folderIdentifier)
823  {
824  $identifier = $folderIdentifier . '/' . $fileName;
825  $identifier = $this->‪canonicalizeAndCheckFileIdentifier($identifier);
826  return $this->‪fileExists($identifier);
827  }
828 
836  public function ‪folderExists($folderIdentifier)
837  {
838  $absoluteFilePath = $this->‪getAbsolutePath($folderIdentifier);
839  return is_dir($absoluteFilePath);
840  }
841 
849  public function ‪folderExistsInFolder($folderName, $folderIdentifier)
850  {
851  $identifier = $folderIdentifier . '/' . $folderName;
852  $identifier = $this->‪canonicalizeAndCheckFolderIdentifier($identifier);
853  return $this->‪folderExists($identifier);
854  }
855 
863  public function ‪getFolderInFolder($folderName, $folderIdentifier)
864  {
865  $folderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($folderIdentifier . '/' . $folderName);
866  return $folderIdentifier;
867  }
868 
877  public function ‪replaceFile($fileIdentifier, $localFilePath)
878  {
879  $filePath = $this->‪getAbsolutePath($fileIdentifier);
880  if (is_uploaded_file($localFilePath)) {
881  $result = move_uploaded_file($localFilePath, $filePath);
882  } else {
883  $result = rename($localFilePath, $filePath);
884  }
885  GeneralUtility::fixPermissions($filePath);
886  if ($result === false) {
887  throw new \RuntimeException('Replacing file ' . $fileIdentifier . ' with ' . $localFilePath . ' failed.', 1315314711);
888  }
889  return $result;
890  }
891 
902  public function ‪copyFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $fileName)
903  {
904  $sourcePath = $this->‪getAbsolutePath($fileIdentifier);
905  $newIdentifier = $targetFolderIdentifier . '/' . $fileName;
906  $newIdentifier = $this->‪canonicalizeAndCheckFileIdentifier($newIdentifier);
907 
908  $absoluteFilePath = $this->‪getAbsolutePath($newIdentifier);
909  copy($sourcePath, $absoluteFilePath);
910  GeneralUtility::fixPermissions($absoluteFilePath);
911  return $newIdentifier;
912  }
913 
925  public function ‪moveFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $newFileName)
926  {
927  $sourcePath = $this->‪getAbsolutePath($fileIdentifier);
928  $targetIdentifier = $targetFolderIdentifier . '/' . $newFileName;
929  $targetIdentifier = $this->‪canonicalizeAndCheckFileIdentifier($targetIdentifier);
930  $result = rename($sourcePath, $this->‪getAbsolutePath($targetIdentifier));
931  if ($result === false) {
932  throw new \RuntimeException('Moving file ' . $sourcePath . ' to ' . $targetIdentifier . ' failed.', 1315314712);
933  }
934  return $targetIdentifier;
935  }
936 
944  protected function ‪copyFileToTemporaryPath($fileIdentifier)
945  {
946  $sourcePath = $this->‪getAbsolutePath($fileIdentifier);
947  $temporaryPath = $this->‪getTemporaryPathForFile($fileIdentifier);
948  $result = copy($sourcePath, $temporaryPath);
949  touch($temporaryPath, filemtime($sourcePath));
950  if ($result === false) {
951  throw new \RuntimeException(
952  'Copying file "' . $fileIdentifier . '" to temporary path "' . $temporaryPath . '" failed.',
953  1320577649
954  );
955  }
956  return $temporaryPath;
957  }
958 
967  protected function ‪recycleFileOrFolder($filePath, $recycleDirectory)
968  {
969  $destinationFile = $recycleDirectory . '/' . ‪PathUtility::basename($filePath);
970  if (file_exists($destinationFile)) {
971  $timeStamp = \DateTimeImmutable::createFromFormat('U.u', microtime(true))->format('YmdHisu');
972  $destinationFile = $recycleDirectory . '/' . $timeStamp . '_' . ‪PathUtility::basename($filePath);
973  }
974  $result = rename($filePath, $destinationFile);
975  // Update the mtime for the file, so the recycler garbage collection task knows which files to delete
976  // Using ctime() is not possible there since this is not supported on Windows
977  if ($result) {
978  touch($destinationFile);
979  }
980  return $result;
981  }
982 
994  protected function ‪createIdentifierMap(array $filesAndFolders, $sourceFolderIdentifier, $targetFolderIdentifier)
995  {
996  $identifierMap = [];
997  $identifierMap[$sourceFolderIdentifier] = $targetFolderIdentifier;
998  foreach ($filesAndFolders as $oldItem) {
999  if ($oldItem['type'] === 'dir') {
1000  $oldIdentifier = $oldItem['identifier'];
1001  $newIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier(
1002  str_replace($sourceFolderIdentifier, $targetFolderIdentifier, $oldItem['identifier'])
1003  );
1004  } else {
1005  $oldIdentifier = $oldItem['identifier'];
1006  $newIdentifier = $this->‪canonicalizeAndCheckFileIdentifier(
1007  str_replace($sourceFolderIdentifier, $targetFolderIdentifier, $oldItem['identifier'])
1008  );
1009  }
1010  if (!file_exists($this->‪getAbsolutePath($newIdentifier))) {
1011  throw new Exception\FileOperationErrorException(
1012  sprintf('File "%1$s" was not found (should have been copied/moved from "%2$s").', $newIdentifier, $oldIdentifier),
1013  1330119453
1014  );
1015  }
1016  $identifierMap[$oldIdentifier] = $newIdentifier;
1017  }
1018  return $identifierMap;
1019  }
1020 
1031  public function ‪moveFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName)
1032  {
1033  $sourcePath = $this->‪getAbsolutePath($sourceFolderIdentifier);
1034  $relativeTargetPath = $this->‪canonicalizeAndCheckFolderIdentifier($targetFolderIdentifier . '/' . $newFolderName);
1035  $targetPath = $this->‪getAbsolutePath($relativeTargetPath);
1036  // get all files and folders we are going to move, to have a map for updating later.
1037  $filesAndFolders = $this->‪retrieveFileAndFoldersInPath($sourcePath, true);
1038  $result = rename($sourcePath, $targetPath);
1039  if ($result === false) {
1040  throw new \RuntimeException('Moving folder ' . $sourcePath . ' to ' . $targetPath . ' failed.', 1320711817);
1041  }
1042  // Create a mapping from old to new identifiers
1043  $identifierMap = $this->‪createIdentifierMap($filesAndFolders, $sourceFolderIdentifier, $relativeTargetPath);
1044  return $identifierMap;
1045  }
1046 
1057  public function ‪copyFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName)
1058  {
1059  // This target folder path already includes the topmost level, i.e. the folder this method knows as $folderToCopy.
1060  // We can thus rely on this folder being present and just create the subfolder we want to copy to.
1061  $newFolderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($targetFolderIdentifier . '/' . $newFolderName);
1062  $sourceFolderPath = $this->‪getAbsolutePath($sourceFolderIdentifier);
1063  $targetFolderPath = $this->‪getAbsolutePath($newFolderIdentifier);
1064 
1065  mkdir($targetFolderPath);
1067  $iterator = new \RecursiveIteratorIterator(
1068  new \RecursiveDirectoryIterator($sourceFolderPath),
1069  \RecursiveIteratorIterator::SELF_FIRST,
1070  \RecursiveIteratorIterator::CATCH_GET_CHILD
1071  );
1072  // Rewind the iterator as this is important for some systems e.g. Windows
1073  $iterator->rewind();
1074  while ($iterator->valid()) {
1076  $current = $iterator->current();
1077  $fileName = $current->getFilename();
1078  $itemSubPath = GeneralUtility::fixWindowsFilePath($iterator->getSubPathname());
1079  if ($current->isDir() && !($fileName === '..' || $fileName === '.')) {
1080  GeneralUtility::mkdir($targetFolderPath . '/' . $itemSubPath);
1081  } elseif ($current->isFile()) {
1082  $copySourcePath = $sourceFolderPath . '/' . $itemSubPath;
1083  $copyTargetPath = $targetFolderPath . '/' . $itemSubPath;
1084  $result = copy($copySourcePath, $copyTargetPath);
1085  if ($result === false) {
1086  // rollback
1087  GeneralUtility::rmdir($targetFolderIdentifier, true);
1088  throw new Exception\FileOperationErrorException(
1089  'Copying resource "' . $copySourcePath . '" to "' . $copyTargetPath . '" failed.',
1090  1330119452
1091  );
1092  }
1093  }
1094  $iterator->next();
1095  }
1096  GeneralUtility::fixPermissions($targetFolderPath, true);
1097  return true;
1098  }
1099 
1109  public function ‪renameFile($fileIdentifier, $newName)
1110  {
1111  // Makes sure the Path given as parameter is valid
1112  $newName = $this->‪sanitizeFileName($newName);
1113  $newIdentifier = rtrim(GeneralUtility::fixWindowsFilePath(‪PathUtility::dirname($fileIdentifier)), '/') . '/' . $newName;
1114  $newIdentifier = $this->‪canonicalizeAndCheckFileIdentifier($newIdentifier);
1115  // The target should not exist already
1116  if ($this->‪fileExists($newIdentifier)) {
1117  throw new Exception\ExistingTargetFileNameException(
1118  'The target file "' . $newIdentifier . '" already exists.',
1119  1320291063
1120  );
1121  }
1122  $sourcePath = $this->‪getAbsolutePath($fileIdentifier);
1123  $targetPath = $this->‪getAbsolutePath($newIdentifier);
1124  $result = rename($sourcePath, $targetPath);
1125  if ($result === false) {
1126  throw new \RuntimeException('Renaming file ' . $sourcePath . ' to ' . $targetPath . ' failed.', 1320375115);
1127  }
1128  return $newIdentifier;
1129  }
1130 
1139  public function ‪renameFolder($folderIdentifier, $newName)
1140  {
1141  $folderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
1142  $newName = $this->‪sanitizeFileName($newName);
1143 
1144  $newIdentifier = ‪PathUtility::dirname($folderIdentifier) . '/' . $newName;
1145  $newIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($newIdentifier);
1146 
1147  $sourcePath = $this->‪getAbsolutePath($folderIdentifier);
1148  $targetPath = $this->‪getAbsolutePath($newIdentifier);
1149  // get all files and folders we are going to move, to have a map for updating later.
1150  $filesAndFolders = $this->‪retrieveFileAndFoldersInPath($sourcePath, true);
1151  $result = rename($sourcePath, $targetPath);
1152  if ($result === false) {
1153  throw new \RuntimeException(sprintf('Renaming folder "%1$s" to "%2$s" failed."', $sourcePath, $targetPath), 1320375116);
1154  }
1155  try {
1156  // Create a mapping from old to new identifiers
1157  $identifierMap = $this->‪createIdentifierMap($filesAndFolders, $folderIdentifier, $newIdentifier);
1158  } catch (\Exception $e) {
1159  rename($targetPath, $sourcePath);
1160  throw new \RuntimeException(
1161  sprintf(
1162  'Creating filename mapping after renaming "%1$s" to "%2$s" failed. Reverted rename operation.\\n\\nOriginal error: %3$s"',
1163  $sourcePath,
1164  $targetPath,
1165  $e->getMessage()
1166  ),
1167  1334160746
1168  );
1169  }
1170  return $identifierMap;
1171  }
1172 
1182  public function ‪deleteFile($fileIdentifier)
1183  {
1184  $filePath = $this->‪getAbsolutePath($fileIdentifier);
1185  $result = unlink($filePath);
1186 
1187  if ($result === false) {
1188  throw new \RuntimeException('Deletion of file ' . $fileIdentifier . ' failed.', 1320855304);
1189  }
1190  return $result;
1191  }
1192 
1202  public function ‪deleteFolder($folderIdentifier, $deleteRecursively = false)
1203  {
1204  $folderPath = $this->‪getAbsolutePath($folderIdentifier);
1205  $recycleDirectory = $this->‪getRecycleDirectory($folderPath);
1206  if (!empty($recycleDirectory) && $folderPath !== $recycleDirectory) {
1207  $result = $this->‪recycleFileOrFolder($folderPath, $recycleDirectory);
1208  } else {
1209  $result = GeneralUtility::rmdir($folderPath, $deleteRecursively);
1210  }
1211  if ($result === false) {
1212  throw new Exception\FileOperationErrorException(
1213  'Deleting folder "' . $folderIdentifier . '" failed.',
1214  1330119451
1215  );
1216  }
1217  return $result;
1218  }
1219 
1226  public function ‪isFolderEmpty($folderIdentifier)
1227  {
1228  $path = $this->‪getAbsolutePath($folderIdentifier);
1229  $dirHandle = opendir($path);
1230  while ($entry = readdir($dirHandle)) {
1231  if ($entry !== '.' && $entry !== '..') {
1232  closedir($dirHandle);
1233  return false;
1234  }
1235  }
1236  closedir($dirHandle);
1237  return true;
1238  }
1239 
1250  public function ‪getFileForLocalProcessing($fileIdentifier, $writable = true)
1251  {
1252  if ($writable === false) {
1253  return $this->‪getAbsolutePath($fileIdentifier);
1254  }
1255  return $this->‪copyFileToTemporaryPath($fileIdentifier);
1256  }
1257 
1265  public function ‪getPermissions($identifier)
1266  {
1267  $path = $this->‪getAbsolutePath($identifier);
1268  $permissionBits = fileperms($path);
1269  if ($permissionBits === false) {
1270  throw new Exception\ResourcePermissionsUnavailableException('Error while fetching permissions for ' . $path, 1319455097);
1271  }
1272  return [
1273  'r' => (bool)is_readable($path),
1274  'w' => (bool)is_writable($path)
1275  ];
1276  }
1277 
1287  public function ‪isWithin($folderIdentifier, $identifier)
1288  {
1289  $folderIdentifier = $this->‪canonicalizeAndCheckFileIdentifier($folderIdentifier);
1290  $entryIdentifier = $this->‪canonicalizeAndCheckFileIdentifier($identifier);
1291  if ($folderIdentifier === $entryIdentifier) {
1292  return true;
1293  }
1294  // File identifier canonicalization will not modify a single slash so
1295  // we must not append another slash in that case.
1296  if ($folderIdentifier !== '/') {
1297  $folderIdentifier .= '/';
1298  }
1299  return GeneralUtility::isFirstPartOfStr($entryIdentifier, $folderIdentifier);
1300  }
1301 
1310  public function ‪createFile($fileName, $parentFolderIdentifier)
1311  {
1312  $fileName = $this->‪sanitizeFileName(ltrim($fileName, '/'));
1313  $parentFolderIdentifier = $this->‪canonicalizeAndCheckFolderIdentifier($parentFolderIdentifier);
1314  $fileIdentifier = $this->‪canonicalizeAndCheckFileIdentifier(
1315  $parentFolderIdentifier . $fileName
1316  );
1317  $absoluteFilePath = $this->‪getAbsolutePath($fileIdentifier);
1318  $result = touch($absoluteFilePath);
1319  GeneralUtility::fixPermissions($absoluteFilePath);
1320  clearstatcache();
1321  if ($result !== true) {
1322  throw new \RuntimeException('Creating file ' . $fileIdentifier . ' failed.', 1320569854);
1323  }
1324  return $fileIdentifier;
1325  }
1326 
1336  public function ‪getFileContents($fileIdentifier)
1337  {
1338  $filePath = $this->‪getAbsolutePath($fileIdentifier);
1339  return file_get_contents($filePath);
1340  }
1341 
1350  public function ‪setFileContents($fileIdentifier, $contents)
1351  {
1352  $filePath = $this->‪getAbsolutePath($fileIdentifier);
1353  $result = file_put_contents($filePath, $contents);
1354 
1355  // Make sure later calls to filesize() etc. return correct values.
1356  clearstatcache(true, $filePath);
1357 
1358  if ($result === false) {
1359  throw new \RuntimeException('Setting contents of file "' . $fileIdentifier . '" failed.', 1325419305);
1360  }
1361  return $result;
1362  }
1363 
1370  public function ‪getRole($folderIdentifier)
1371  {
1372  $name = ‪PathUtility::basename($folderIdentifier);
1373  $role = $this->mappingFolderNameToRole[$name] ?? ‪FolderInterface::ROLE_DEFAULT;
1374  return $role;
1375  }
1376 
1384  public function ‪dumpFileContents($identifier)
1385  {
1386  readfile($this->‪getAbsolutePath($this->‪canonicalizeAndCheckFileIdentifier($identifier)), 0);
1387  }
1388 
1396  public function ‪streamFile(string $identifier, array $properties): ResponseInterface
1397  {
1398  $fileInfo = $this->‪getFileInfoByIdentifier($identifier, ['name', 'mimetype', 'mtime', 'size']);
1399  $downloadName = $properties['filename_overwrite'] ?? $fileInfo['name'] ?? '';
1400  $mimeType = $properties['mimetype_overwrite'] ?? $fileInfo['mimetype'] ?? '';
1401  $contentDisposition = ($properties['as_download'] ?? false) ? 'attachment' : 'inline';
1402 
1403  $filePath = $this->‪getAbsolutePath($this->‪canonicalizeAndCheckFileIdentifier($identifier));
1404 
1405  return new Response(
1406  new SelfEmittableLazyOpenStream($filePath),
1407  200,
1408  [
1409  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1410  'Content-Type' => $mimeType,
1411  'Content-Length' => (string)$fileInfo['size'],
1412  'Last-Modified' => gmdate('D, d M Y H:i:s', $fileInfo['mtime']) . ' GMT',
1413  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1414  // See for more information: http://support.microsoft.com/kb/323308
1415  'Cache-Control' => '',
1416  ]
1417  );
1418  }
1419 
1427  protected function ‪getRecycleDirectory($path)
1428  {
1429  $recyclerSubdirectory = array_search(‪FolderInterface::ROLE_RECYCLER, $this->mappingFolderNameToRole, true);
1430  if ($recyclerSubdirectory === false) {
1431  return '';
1432  }
1433  $rootDirectory = rtrim($this->‪getAbsolutePath($this->‪getRootLevelFolder()), '/');
1434  $searchDirectory = ‪PathUtility::dirname($path);
1435  // Check if file or folder to be deleted is inside a recycler directory
1436  if ($this->‪getRole($searchDirectory) === ‪FolderInterface::ROLE_RECYCLER) {
1437  $searchDirectory = ‪PathUtility::dirname($searchDirectory);
1438  // Check if file or folder to be deleted is inside the root recycler
1439  if ($searchDirectory == $rootDirectory) {
1440  return '';
1441  }
1442  $searchDirectory = ‪PathUtility::dirname($searchDirectory);
1443  }
1444  // Search for the closest recycler directory
1445  while ($searchDirectory) {
1446  $recycleDirectory = $searchDirectory . '/' . $recyclerSubdirectory;
1447  if (is_dir($recycleDirectory)) {
1448  return $recycleDirectory;
1449  }
1450  if ($searchDirectory === $rootDirectory) {
1451  return '';
1452  }
1453  $searchDirectory = ‪PathUtility::dirname($searchDirectory);
1454  }
1455 
1456  return '';
1457  }
1458 }
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\retrieveFileAndFoldersInPath
‪array retrieveFileAndFoldersInPath($path, $recursive=false, $includeFiles=true, $includeDirs=true, $sort='', $sortRev=false)
Definition: LocalDriver.php:526
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getRole
‪string getRole($folderIdentifier)
Definition: LocalDriver.php:1366
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$capabilities
‪int $capabilities
Definition: AbstractDriver.php:32
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\__construct
‪__construct(array $configuration=[])
Definition: LocalDriver.php:67
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\$absoluteBasePath
‪string $absoluteBasePath
Definition: LocalDriver.php:43
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\folderExistsInFolder
‪bool folderExistsInFolder($folderName, $folderIdentifier)
Definition: LocalDriver.php:845
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\deleteFolder
‪bool deleteFolder($folderIdentifier, $deleteRecursively=false)
Definition: LocalDriver.php:1198
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver\canonicalizeAndCheckFilePath
‪string canonicalizeAndCheckFilePath($filePath)
Definition: AbstractHierarchicalFilesystemDriver.php:66
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\determineBaseUrl
‪determineBaseUrl()
Definition: LocalDriver.php:118
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\recycleFileOrFolder
‪bool recycleFileOrFolder($filePath, $recycleDirectory)
Definition: LocalDriver.php:963
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFilesInFolder
‪array getFilesInFolder($folderIdentifier, $start=0, $numberOfItems=0, $recursive=false, array $filenameFilterCallbacks=[], $sort='', $sortRev=false)
Definition: LocalDriver.php:459
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver\canonicalizeAndCheckFolderIdentifier
‪string canonicalizeAndCheckFolderIdentifier($folderPath)
Definition: AbstractHierarchicalFilesystemDriver.php:103
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\addFile
‪string addFile($localFilePath, $targetFolderIdentifier, $newFileName='', $removeOriginal=true)
Definition: LocalDriver.php:764
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver\canonicalizeAndCheckFileIdentifier
‪string canonicalizeAndCheckFileIdentifier($fileIdentifier)
Definition: AbstractHierarchicalFilesystemDriver.php:85
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:185
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$configuration
‪array $configuration
Definition: AbstractDriver.php:52
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver
Definition: AbstractHierarchicalFilesystemDriver.php:26
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\renameFile
‪string renameFile($fileIdentifier, $newName)
Definition: LocalDriver.php:1105
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\countFilesInFolder
‪int countFilesInFolder($folderIdentifier, $recursive=false, array $filenameFilterCallbacks=[])
Definition: LocalDriver.php:472
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:25
‪TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix
‪static string stripPathSitePrefix($path)
Definition: PathUtility.php:371
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver
Definition: LocalDriver.php:33
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFolderInfoByIdentifier
‪array getFolderInfoByIdentifier($folderIdentifier)
Definition: LocalDriver.php:274
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\extractFileInformation
‪array extractFileInformation($filePath, $containerPath, array $propertiesToExtract=[])
Definition: LocalDriver.php:641
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hashIdentifier
‪string hashIdentifier($identifier)
Definition: AbstractDriver.php:137
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\streamFile
‪ResponseInterface streamFile(string $identifier, array $properties)
Definition: LocalDriver.php:1392
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFileForLocalProcessing
‪string getFileForLocalProcessing($fileIdentifier, $writable=true)
Definition: LocalDriver.php:1246
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\sortDirectoryEntries
‪array sortDirectoryEntries($directoryEntries, $sort='', $sortRev=false)
Definition: LocalDriver.php:585
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getDefaultFolder
‪string getDefaultFolder()
Definition: LocalDriver.php:206
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\isFolderEmpty
‪bool isFolderEmpty($folderIdentifier)
Definition: LocalDriver.php:1222
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USERUPLOAD
‪const ROLE_USERUPLOAD
Definition: FolderInterface.php:29
‪TYPO3\CMS\Core\Charset\CharsetConverter
Definition: CharsetConverter.php:54
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\countFoldersInFolder
‪int countFoldersInFolder($folderIdentifier, $recursive=false, array $folderNameFilterCallbacks=[])
Definition: LocalDriver.php:506
‪$dir
‪$dir
Definition: validateRstFiles.php:213
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\createFolder
‪string createFolder($newFolderName, $parentFolderIdentifier='', $recursive=false)
Definition: LocalDriver.php:225
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\deleteFile
‪bool deleteFile($fileIdentifier)
Definition: LocalDriver.php:1178
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getSpecificFileInformation
‪bool int string getSpecificFileInformation($fileIdentifier, $containerPath, $property)
Definition: LocalDriver.php:666
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getAbsolutePath
‪string getAbsolutePath($fileIdentifier)
Definition: LocalDriver.php:717
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string array pathinfo($path, $options=null)
Definition: PathUtility.php:207
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static string basename($path)
Definition: PathUtility.php:164
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\initialize
‪initialize()
Definition: LocalDriver.php:110
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_TEMPORARY
‪const ROLE_TEMPORARY
Definition: FolderInterface.php:28
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getTemporaryPathForFile
‪string getTemporaryPathForFile($fileIdentifier)
Definition: AbstractDriver.php:124
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\createFile
‪string createFile($fileName, $parentFolderIdentifier)
Definition: LocalDriver.php:1306
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getRecycleDirectory
‪string getRecycleDirectory($path)
Definition: LocalDriver.php:1423
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\setFileContents
‪int setFileContents($fileIdentifier, $contents)
Definition: LocalDriver.php:1346
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:28
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\$baseUri
‪string $baseUri
Definition: LocalDriver.php:56
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\hash
‪string hash($fileIdentifier, $hashAlgorithm)
Definition: LocalDriver.php:733
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getPublicUrl
‪string null getPublicUrl($identifier)
Definition: LocalDriver.php:179
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hasCapability
‪bool hasCapability($capability)
Definition: AbstractDriver.php:109
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\$supportedHashAlgorithms
‪array $supportedHashAlgorithms
Definition: LocalDriver.php:49
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\moveFileWithinStorage
‪string moveFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $newFileName)
Definition: LocalDriver.php:921
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\folderExists
‪bool folderExists($folderIdentifier)
Definition: LocalDriver.php:832
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFileInfoByIdentifier
‪array getFileInfoByIdentifier($fileIdentifier, array $propertiesToExtract=[])
Definition: LocalDriver.php:253
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\$mappingFolderNameToRole
‪array $mappingFolderNameToRole
Definition: LocalDriver.php:58
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\mergeConfigurationCapabilities
‪int mergeConfigurationCapabilities($capabilities)
Definition: LocalDriver.php:86
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\dumpFileContents
‪dumpFileContents($identifier)
Definition: LocalDriver.php:1380
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_HIERARCHICAL_IDENTIFIERS
‪const CAPABILITY_HIERARCHICAL_IDENTIFIERS
Definition: ResourceStorageInterface.php:67
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\isWithin
‪bool isWithin($folderIdentifier, $identifier)
Definition: LocalDriver.php:1283
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: ResourceStorageInterface.php:54
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFileContents
‪string getFileContents($fileIdentifier)
Definition: LocalDriver.php:1332
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\copyFileToTemporaryPath
‪string copyFileToTemporaryPath($fileIdentifier)
Definition: LocalDriver.php:940
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\processConfiguration
‪processConfiguration()
Definition: LocalDriver.php:96
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getAbsoluteBasePath
‪string getAbsoluteBasePath()
Definition: LocalDriver.php:705
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\createIdentifierMap
‪array createIdentifierMap(array $filesAndFolders, $sourceFolderIdentifier, $targetFolderIdentifier)
Definition: LocalDriver.php:990
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:74
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\calculateBasePath
‪string calculateBasePath(array $configuration)
Definition: LocalDriver.php:145
‪TYPO3\CMS\Core\Resource\Driver
Definition: AbstractDriver.php:2
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\copyFolderWithinStorage
‪bool copyFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName)
Definition: LocalDriver.php:1053
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER
‪const ROLE_RECYCLER
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:21
‪TYPO3\CMS\Core\Type\File\FileInfo
Definition: FileInfo.php:24
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\replaceFile
‪bool replaceFile($fileIdentifier, $localFilePath)
Definition: LocalDriver.php:873
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_PUBLIC
‪const CAPABILITY_PUBLIC
Definition: ResourceStorageInterface.php:58
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getDirectoryItemList
‪array getDirectoryItemList($folderIdentifier, $start=0, $numberOfItems=0, array $filterMethods, $includeFiles=true, $includeDirs=true, $recursive=false, $sort='', $sortRev=false)
Definition: LocalDriver.php:347
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\renameFolder
‪array renameFolder($folderIdentifier, $newName)
Definition: LocalDriver.php:1135
‪TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver\getParentFolderIdentifierOfIdentifier
‪mixed getParentFolderIdentifierOfIdentifier($fileIdentifier)
Definition: AbstractHierarchicalFilesystemDriver.php:119
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$storageUid
‪int $storageUid
Definition: AbstractDriver.php:38
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\fileExistsInFolder
‪bool fileExistsInFolder($fileName, $folderIdentifier)
Definition: LocalDriver.php:818
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\fileExists
‪bool fileExists($fileIdentifier)
Definition: LocalDriver.php:805
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\moveFolderWithinStorage
‪array moveFolderWithinStorage($sourceFolderIdentifier, $targetFolderIdentifier, $newFolderName)
Definition: LocalDriver.php:1027
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\applyFilterMethodsToDirectoryItem
‪bool applyFilterMethodsToDirectoryItem(array $filterMethods, $itemName, $itemIdentifier, $parentIdentifier)
Definition: LocalDriver.php:410
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFileInFolder
‪string getFileInFolder($fileName, $folderIdentifier)
Definition: LocalDriver.php:438
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream
Definition: SelfEmittableLazyOpenStream.php:29
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\UNSAFE_FILENAME_CHARACTER_EXPRESSION
‪const UNSAFE_FILENAME_CHARACTER_EXPRESSION
Definition: LocalDriver.php:37
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='utf-8')
Definition: LocalDriver.php:306
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getPermissions
‪array getPermissions($identifier)
Definition: LocalDriver.php:1261
‪TYPO3\CMS\Core\Resource\Exception\InvalidPathException
Definition: InvalidPathException.php:21
‪TYPO3\CMS\Core\Resource\Driver\StreamableDriverInterface
Definition: StreamableDriverInterface.php:28
‪TYPO3\CMS\Core\Resource\Exception
Definition: AbstractFileOperationException.php:2
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFoldersInFolder
‪array getFoldersInFolder($folderIdentifier, $start=0, $numberOfItems=0, $recursive=false, array $folderNameFilterCallbacks=[], $sort='', $sortRev=false)
Definition: LocalDriver.php:493
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getFolderInFolder
‪string getFolderInFolder($folderName, $folderIdentifier)
Definition: LocalDriver.php:859
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: ResourceStorageInterface.php:63
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\getRootLevelFolder
‪string getRootLevelFolder()
Definition: LocalDriver.php:196
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\copyFileWithinStorage
‪string copyFileWithinStorage($fileIdentifier, $targetFolderIdentifier, $fileName)
Definition: LocalDriver.php:898