TYPO3 CMS  TYPO3_6-2
AbstractHierarchicalFilesystemDriver.php
Go to the documentation of this file.
1 <?php
3 
21 
29  protected function isPathValid($theFile) {
30  return \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr($theFile);
31  }
32 
40  protected function canonicalizeAndCheckFilePath($filePath) {
42 
43  // filePath must be valid
44  // Special case is required by vfsStream in Unit Test context
45  if (!$this->isPathValid($filePath) && substr($filePath, 0, 6) !== 'vfs://') {
46  throw new \TYPO3\CMS\Core\Resource\Exception\InvalidPathException('File ' . $filePath . ' is not valid (".." and "//" is not allowed in path).', 1320286857);
47  }
48  return $filePath;
49  }
50 
58  protected function canonicalizeAndCheckFileIdentifier($fileIdentifier) {
59  if ($fileIdentifier !== '') {
60  $fileIdentifier = $this->canonicalizeAndCheckFilePath($fileIdentifier);
61  $fileIdentifier = '/' . ltrim($fileIdentifier, '/');
62  if (!$this->isCaseSensitiveFileSystem()) {
63  $fileIdentifier = strtolower($fileIdentifier);
64  }
65  }
66  return $fileIdentifier;
67  }
68 
75  protected function canonicalizeAndCheckFolderIdentifier($folderPath) {
76  if ($folderPath === '/') {
77  $canonicalizedIdentifier = $folderPath;
78  } else {
79  $canonicalizedIdentifier = rtrim($this->canonicalizeAndCheckFileIdentifier($folderPath), '/') . '/';
80  }
81  return $canonicalizedIdentifier;
82  }
83 
90  public function getParentFolderIdentifierOfIdentifier($fileIdentifier) {
91  $fileIdentifier = $this->canonicalizeAndCheckFileIdentifier($fileIdentifier);
92  return \TYPO3\CMS\Core\Utility\PathUtility::dirname($fileIdentifier) . '/';
93  }
94 
95 
96 }