TYPO3 CMS  TYPO3_7-6
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 
23 abstract class AbstractDriver implements DriverInterface
24 {
25  /*******************
26  * CAPABILITIES
27  *******************/
34  protected $capabilities = 0;
35 
41  protected $storageUid;
42 
50  protected $supportedHashAlgorithms = [];
51 
57  protected $configuration = [];
58 
64  public function __construct(array $configuration = [])
65  {
66  $this->configuration = $configuration;
67  }
68 
76  protected function isValidFilename($fileName)
77  {
78  if (strpos($fileName, '/') !== false) {
79  return false;
80  }
81  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
82  return false;
83  }
84  return true;
85  }
86 
93  public function setStorageUid($storageUid)
94  {
95  $this->storageUid = $storageUid;
96  }
97 
104  public function getCapabilities()
105  {
106  return $this->capabilities;
107  }
108 
115  public function hasCapability($capability)
116  {
117  return $this->capabilities & $capability == $capability;
118  }
119 
120  /*******************
121  * FILE FUNCTIONS
122  *******************/
123 
130  protected function getTemporaryPathForFile($fileIdentifier)
131  {
132  return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-', '.' . PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
133  }
134 
143  public function hashIdentifier($identifier)
144  {
145  $identifier = $this->canonicalizeAndCheckFileIdentifier($identifier);
146  return sha1($identifier);
147  }
148 
157  public function sanitizeFileName($fileName, $charset = '')
158  {
159  return $fileName;
160  }
161 
171  public function isCaseSensitiveFileSystem()
172  {
173  if (isset($this->configuration['caseSensitive'])) {
174  return (bool)$this->configuration['caseSensitive'];
175  }
176  return true;
177  }
178 
185  abstract protected function canonicalizeAndCheckFilePath($filePath);
186 
194  abstract protected function canonicalizeAndCheckFileIdentifier($fileIdentifier);
195 
202  abstract protected function canonicalizeAndCheckFolderIdentifier($folderIdentifier);
203 }
canonicalizeAndCheckFolderIdentifier($folderIdentifier)
static pathinfo($path, $options=null)