TYPO3  7.6
AbstractDriver.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Driver;
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 
23 abstract class AbstractDriver implements DriverInterface
24 {
25  /*******************
26  * CAPABILITIES
27  *******************/
34  protected $capabilities = 0;
35 
36 
42  protected $storageUid;
43 
51  protected $supportedHashAlgorithms = array();
52 
58  protected $configuration = array();
59 
65  public function __construct(array $configuration = array())
66  {
67  $this->configuration = $configuration;
68  }
69 
77  protected function isValidFilename($fileName)
78  {
79  if (strpos($fileName, '/') !== false) {
80  return false;
81  }
82  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
83  return false;
84  }
85  return true;
86  }
87 
94  public function setStorageUid($storageUid)
95  {
96  $this->storageUid = $storageUid;
97  }
98 
105  public function getCapabilities()
106  {
107  return $this->capabilities;
108  }
109 
116  public function hasCapability($capability)
117  {
118  return $this->capabilities & $capability == $capability;
119  }
120 
121  /*******************
122  * FILE FUNCTIONS
123  *******************/
124 
131  protected function getTemporaryPathForFile($fileIdentifier)
132  {
133  return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-', '.' . PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
134  }
135 
144  public function hashIdentifier($identifier)
145  {
146  $identifier = $this->canonicalizeAndCheckFileIdentifier($identifier);
147  return sha1($identifier);
148  }
149 
158  public function sanitizeFileName($fileName, $charset = '')
159  {
160  return $fileName;
161  }
162 
172  public function isCaseSensitiveFileSystem()
173  {
174  if (isset($this->configuration['caseSensitive'])) {
175  return (bool)$this->configuration['caseSensitive'];
176  }
177  return true;
178  }
179 
186  abstract protected function canonicalizeAndCheckFilePath($filePath);
187 
195  abstract protected function canonicalizeAndCheckFileIdentifier($fileIdentifier);
196 
203  abstract protected function canonicalizeAndCheckFolderIdentifier($folderIdentifier);
204 }