TYPO3 CMS  TYPO3_8-7
AbstractDriver.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 
18 
22 abstract class AbstractDriver implements DriverInterface
23 {
24  /*******************
25  * CAPABILITIES
26  *******************/
33  protected $capabilities = 0;
34 
40  protected $storageUid;
41 
49  protected $supportedHashAlgorithms = [];
50 
56  protected $configuration = [];
57 
63  public function __construct(array $configuration = [])
64  {
65  $this->configuration = $configuration;
66  }
67 
75  protected function isValidFilename($fileName)
76  {
77  if (strpos($fileName, '/') !== false) {
78  return false;
79  }
80  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
81  return false;
82  }
83  return true;
84  }
85 
91  public function setStorageUid($storageUid)
92  {
93  $this->storageUid = $storageUid;
94  }
95 
102  public function getCapabilities()
103  {
104  return $this->capabilities;
105  }
106 
113  public function hasCapability($capability)
114  {
115  return $this->capabilities & $capability == $capability;
116  }
117 
118  /*******************
119  * FILE FUNCTIONS
120  *******************/
121 
128  protected function getTemporaryPathForFile($fileIdentifier)
129  {
130  return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-', '.' . PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
131  }
132 
141  public function hashIdentifier($identifier)
142  {
143  $identifier = $this->canonicalizeAndCheckFileIdentifier($identifier);
144  return sha1($identifier);
145  }
146 
155  public function sanitizeFileName($fileName, $charset = '')
156  {
157  return $fileName;
158  }
159 
169  public function isCaseSensitiveFileSystem()
170  {
171  if (isset($this->configuration['caseSensitive'])) {
172  return (bool)$this->configuration['caseSensitive'];
173  }
174  return true;
175  }
176 
183  abstract protected function canonicalizeAndCheckFilePath($filePath);
184 
192  abstract protected function canonicalizeAndCheckFileIdentifier($fileIdentifier);
193 
200  abstract protected function canonicalizeAndCheckFolderIdentifier($folderIdentifier);
201 }
canonicalizeAndCheckFolderIdentifier($folderIdentifier)
static pathinfo($path, $options=null)