LocalDriver

class \TYPO3\CMS\Core\Resource\Driver\LocalDriver

Extends
AbstractHierarchicalFilesystemDriver
Implements
StreamableDriverInterface

Driver for the local file system

Table of Contents

Interfaces

StreamableDriverInterface
An interface FAL drivers have to implement to fulfil the needs of streaming files using PSR-7 Response objects.

Constants

UNSAFE_FILENAME_CHARACTER_EXPRESSION  : string = '\x00-\x2C\/\x3A-\x3F\x5B-\x60\x7B-\xBF'

Properties

$absoluteBasePath  : string
The absolute base path. It always contains a trailing slash.
$baseUri  : string
The base URL that points to this driver's storage. As long is this is not set, it is assumed that this folder is not publicly available
$capabilities  : int
The capabilities of this driver. See \TYPO3\CMS\Core\Resource\ResourceStorageInterface::::CAPABILITY_* constants for possible values. This value should be set in the constructor of derived classes.
$configuration  : array
The configuration of this driver
$mappingFolderNameToRole  : array
$storageUid  : int
The storage uid the driver was instantiated for
$supportedHashAlgorithms  : array
A list of all supported hash algorithms, written all lower case.

Methods

__construct()  : mixed
Creates this object.
addFile()  : string
Adds a file from the local server hard disk to a given path in TYPO3s virtual file system.
copyFileWithinStorage()  : string
Copies a file *within* the current storage.
copyFolderWithinStorage()  : bool
Folder equivalent to copyFileWithinStorage().
countFilesInFolder()  : int
Returns the number of files inside the specified path
countFoldersInFolder()  : int
Returns the number of folders inside the specified path
createFile()  : string
Creates a new (empty) file and returns the identifier.
createFolder()  : string
Creates a folder, within a parent folder.
deleteFile()  : bool
Removes a file from the filesystem. This does not check if the file is still used or if it is a bad idea to delete it for some other reason this has to be taken care of in the upper layers (e.g. the Storage)!
deleteFolder()  : bool
Removes a folder from this storage.
dumpFileContents()  : mixed
Directly output the contents of the file to the output buffer. Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.
fileExists()  : bool
Checks if a file exists.
fileExistsInFolder()  : bool
Checks if a file inside a folder exists
folderExists()  : bool
Checks if a folder exists.
folderExistsInFolder()  : bool
Checks if a folder inside a folder exists.
getCapabilities()  : int
Returns the capabilities of this driver.
getDefaultFolder()  : string
Returns identifier of the default folder new files should be put into.
getFileContents()  : string
Returns the contents of a file. Beware that this requires to load the complete file into memory and also may require fetching the file from an external location. So this might be an expensive operation (both in terms of processing resources and money) for large files.
getFileForLocalProcessing()  : string
Returns (a local copy of) a file for processing it. This makes a copy first when in writable mode, so if you change the file, you have to update it yourself afterwards.
getFileInfoByIdentifier()  : array
Returns information about a file.
getFileInFolder()  : string
Returns a file inside the specified path
getFilesInFolder()  : array
Returns a list of files inside the specified path
getFolderInfoByIdentifier()  : array
Returns information about a folder.
getFolderInFolder()  : string
Returns the Identifier for a folder within a given folder.
getFoldersInFolder()  : array<string|int, string>
Returns a list of folders inside the specified path
getParentFolderIdentifierOfIdentifier()  : mixed
Returns the identifier of the folder the file resides in
getPermissions()  : array
Returns the permissions of a file/folder as an array (keys r, w) of boolean flags
getPublicUrl()  : string|null
Returns the public URL to a file.
getRole()  : string
Returns the role of an item (currently only folders; can later be extended for files as well)
getRootLevelFolder()  : string
Returns the Identifier of the root level folder of the storage.
getSpecificFileInformation()  : bool|int|string
Extracts a specific FileInformation from the FileSystems.
hasCapability()  : bool
Returns TRUE if this driver has the given capability.
hash()  : string
Creates a (cryptographic) hash for a file.
hashIdentifier()  : string
Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.
initialize()  : mixed
Initializes this object. This is called by the storage after the driver has been attached.
isCaseSensitiveFileSystem()  : bool
Returns TRUE if this driver uses case-sensitive identifiers. NOTE: This is a configurable setting, but the setting does not change the way the underlying file system treats the identifiers; the setting should therefore always reflect the file system and not try to change its behaviour
isFolderEmpty()  : bool
Checks if a folder contains files and (if supported) other folders.
isWithin()  : bool
Checks if a given identifier is within a container, e.g. if a file or folder is within another folder. It will also return TRUE if both canonicalized identifiers are equal.
mergeConfigurationCapabilities()  : int
Merges the capabilities merged by the user at the storage configuration into the actual capabilities of the driver and returns the result.
moveFileWithinStorage()  : string
Moves a file *within* the current storage.
moveFolderWithinStorage()  : array
Folder equivalent to moveFileWithinStorage().
processConfiguration()  : mixed
Processes the configuration for this driver.
renameFile()  : string
Renames a file in this storage.
renameFolder()  : array
Renames a folder in this storage.
replaceFile()  : bool
Replaces the contents (and file-specific metadata) of a file object with a local file.
sanitizeFileName()  : string
Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' Trailing dots are removed
setFileContents()  : int
Sets the contents of a file to the specified value.
setStorageUid()  : mixed
Sets the storage uid the driver belongs to
streamFile()  : ResponseInterface
Stream file using a PSR-7 Response object.
applyFilterMethodsToDirectoryItem()  : bool
Applies a set of filter methods to a file name to find out if it should be used or not. This is e.g. used by directory listings.
calculateBasePath()  : string
Calculates the absolute path to this drivers storage location.
canonicalizeAndCheckFileIdentifier()  : string
Makes sure the Path given as parameter is valid
canonicalizeAndCheckFilePath()  : string
Makes sure the Path given as parameter is valid
canonicalizeAndCheckFolderIdentifier()  : string
Makes sure the Path given as parameter is valid
copyFileToTemporaryPath()  : string
Copies a file to a temporary path and returns that path.
createIdentifierMap()  : array
Creates a map of old and new file/folder identifiers after renaming or moving a folder. The old identifier is used as the key, the new one as the value.
determineBaseUrl()  : mixed
Determines the base URL for this driver, from the configuration or the TypoScript frontend object
extractFileInformation()  : array
Extracts information about a file from the filesystem.
getAbsoluteBasePath()  : string
Returns the absolute path of the folder this driver operates on.
getAbsolutePath()  : string
Returns the absolute path of a file or folder.
getDirectoryItemList()  : array<string|int, string>
Generic wrapper for extracting a list of items from a path.
getRecycleDirectory()  : string
Get the path of the nearest recycler folder of a given $path.
getTemporaryPathForFile()  : non-empty-string
Returns a temporary path for a given file, including the file extension.
isAllowedAbsolutePath()  : bool
Wrapper for `GeneralUtility::isAllowedAbsPath`, which implicitly invokes `GeneralUtility::validPathStr` (like in `parent::isPathValid`).
isPathValid()  : bool
Wrapper for \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr()
isValidFilename()  : bool
Checks a fileName for validity. This could be overridden in concrete drivers if they have different file naming rules.
recycleFileOrFolder()  : bool
Moves a file or folder to the given directory, renaming the source in the process if a file or folder of the same name already exists in the target path.
retrieveFileAndFoldersInPath()  : array
Returns a list with the names of all files and folders in a path, optionally recursive.
sortDirectoryEntries()  : array
Sort the directory entries by a certain key

Constants

UNSAFE_FILENAME_CHARACTER_EXPRESSION

public string UNSAFE_FILENAME_CHARACTER_EXPRESSION = '\x00-\x2C\/\x3A-\x3F\x5B-\x60\x7B-\xBF'

Properties

$absoluteBasePath

The absolute base path. It always contains a trailing slash.

protected string $absoluteBasePath

$baseUri

The base URL that points to this driver's storage. As long is this is not set, it is assumed that this folder is not publicly available

protected string $baseUri

$capabilities

The capabilities of this driver. See \TYPO3\CMS\Core\Resource\ResourceStorageInterface::::CAPABILITY_* constants for possible values. This value should be set in the constructor of derived classes.

protected int $capabilities = 0

$configuration

The configuration of this driver

protected array $configuration = []

$mappingFolderNameToRole

protected array $mappingFolderNameToRole = ['_recycler_' => \TYPO3\CMS\Core\Resource\FolderInterface::R…
Show the full value['_recycler_' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_RECYCLER, '_temp_' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_TEMPORARY, 'user_upload' => \TYPO3\CMS\Core\Resource\FolderInterface::ROLE_USERUPLOAD]

$storageUid

The storage uid the driver was instantiated for

protected int $storageUid

$supportedHashAlgorithms

A list of all supported hash algorithms, written all lower case.

protected array $supportedHashAlgorithms = ['sha1', 'md5']

Methods

__construct()

Creates this object.

public __construct([array $configuration = [] ]) : mixed

Parameters

$configuration : array = []

addFile()

Adds a file from the local server hard disk to a given path in TYPO3s virtual file system.

public addFile(string $localFilePath, string $targetFolderIdentifier[, string $newFileName = '' ][, bool $removeOriginal = true ]) : string

This assumes that the local file exists, so no further check is done here! After a successful the original file must not exist anymore.

Parameters

$localFilePath : string

within public web path

$targetFolderIdentifier : string
$newFileName : string = ''

optional, if not given original name is used

$removeOriginal : bool = true

if set the original file will be removed after successful operation

Tags

throws
RuntimeException
throws
InvalidArgumentException

Return values

string —

the identifier of the new file

copyFileWithinStorage()

Copies a file *within* the current storage.

public copyFileWithinStorage(string $fileIdentifier, string $targetFolderIdentifier, string $fileName) : string

Note that this is only about an intra-storage copy action, where a file is just copied to another folder in the same storage.

Parameters

$fileIdentifier : string
$targetFolderIdentifier : string
$fileName : string

Return values

string —

the Identifier of the new file

copyFolderWithinStorage()

Folder equivalent to copyFileWithinStorage().

public copyFolderWithinStorage(string $sourceFolderIdentifier, string $targetFolderIdentifier, string $newFolderName) : bool

Parameters

$sourceFolderIdentifier : string
$targetFolderIdentifier : string
$newFolderName : string

Tags

throws
FileOperationErrorException

Return values

bool

countFilesInFolder()

Returns the number of files inside the specified path

public countFilesInFolder(string $folderIdentifier[, bool $recursive = false ][, array $filenameFilterCallbacks = [] ]) : int

Parameters

$folderIdentifier : string
$recursive : bool = false
$filenameFilterCallbacks : array = []

callbacks for filtering the items

Return values

int —

Number of files in folder

countFoldersInFolder()

Returns the number of folders inside the specified path

public countFoldersInFolder(string $folderIdentifier[, bool $recursive = false ][, array $folderNameFilterCallbacks = [] ]) : int

Parameters

$folderIdentifier : string
$recursive : bool = false
$folderNameFilterCallbacks : array = []

callbacks for filtering the items

Return values

int —

Number of folders in folder

createFile()

Creates a new (empty) file and returns the identifier.

public createFile(string $fileName, string $parentFolderIdentifier) : string

Parameters

$fileName : string
$parentFolderIdentifier : string

Tags

throws
RuntimeException

Return values

string

createFolder()

Creates a folder, within a parent folder.

public createFolder(string $newFolderName[, string $parentFolderIdentifier = '' ][, bool $recursive = false ]) : string

If no parent folder is given, a rootlevel folder will be created

Parameters

$newFolderName : string
$parentFolderIdentifier : string = ''
$recursive : bool = false

Return values

string —

the Identifier of the new folder

deleteFile()

Removes a file from the filesystem. This does not check if the file is still used or if it is a bad idea to delete it for some other reason this has to be taken care of in the upper layers (e.g. the Storage)!

public deleteFile(string $fileIdentifier) : bool

Parameters

$fileIdentifier : string

Tags

throws
RuntimeException

Return values

bool —

TRUE if deleting the file succeeded

deleteFolder()

Removes a folder from this storage.

public deleteFolder(string $folderIdentifier[, bool $deleteRecursively = false ]) : bool

Parameters

$folderIdentifier : string
$deleteRecursively : bool = false

Tags

throws
FileOperationErrorException
throws
InvalidPathException

Return values

bool

dumpFileContents()

Directly output the contents of the file to the output buffer. Should not take care of header files or flushing buffer before. Will be taken care of by the Storage.

public dumpFileContents(string $identifier) : mixed

Parameters

$identifier : string

fileExists()

Checks if a file exists.

public fileExists(string $fileIdentifier) : bool

Parameters

$fileIdentifier : string

Return values

bool

fileExistsInFolder()

Checks if a file inside a folder exists

public fileExistsInFolder(string $fileName, string $folderIdentifier) : bool

Parameters

$fileName : string
$folderIdentifier : string

Return values

bool

folderExists()

Checks if a folder exists.

public folderExists(string $folderIdentifier) : bool

Parameters

$folderIdentifier : string

Return values

bool

folderExistsInFolder()

Checks if a folder inside a folder exists.

public folderExistsInFolder(string $folderName, string $folderIdentifier) : bool

Parameters

$folderName : string
$folderIdentifier : string

Return values

bool

getDefaultFolder()

Returns identifier of the default folder new files should be put into.

public getDefaultFolder() : string

Return values

string

getFileContents()

Returns the contents of a file. Beware that this requires to load the complete file into memory and also may require fetching the file from an external location. So this might be an expensive operation (both in terms of processing resources and money) for large files.

public getFileContents(string $fileIdentifier) : string

Parameters

$fileIdentifier : string

Return values

string —

The file contents if file exists and else empty string

getFileForLocalProcessing()

Returns (a local copy of) a file for processing it. This makes a copy first when in writable mode, so if you change the file, you have to update it yourself afterwards.

public getFileForLocalProcessing(string $fileIdentifier[, bool $writable = true ]) : string

Parameters

$fileIdentifier : string
$writable : bool = true

Set this to FALSE if you only need the file for read operations. This might speed up things, e.g. by using a cached local version. Never modify the file if you have set this flag!

Return values

string —

The path to the file on the local disk

getFileInfoByIdentifier()

Returns information about a file.

public getFileInfoByIdentifier(string $fileIdentifier[, array $propertiesToExtract = [] ]) : array

Parameters

$fileIdentifier : string

In the case of the LocalDriver, this is the (relative) path to the file.

$propertiesToExtract : array = []

Array of properties which should be extracted, if empty all will be extracted

Tags

throws
InvalidArgumentException

Return values

array

getFileInFolder()

Returns a file inside the specified path

public getFileInFolder(string $fileName, string $folderIdentifier) : string

Parameters

$fileName : string
$folderIdentifier : string

Return values

string —

File Identifier

getFilesInFolder()

Returns a list of files inside the specified path

public getFilesInFolder(string $folderIdentifier[, int $start = 0 ][, int $numberOfItems = 0 ][, bool $recursive = false ][, array $filenameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array

Parameters

$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$filenameFilterCallbacks : array = []

The method callbacks to use for filtering the items

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values

array —

of FileIdentifiers

getFolderInfoByIdentifier()

Returns information about a folder.

public getFolderInfoByIdentifier(string $folderIdentifier) : array

Parameters

$folderIdentifier : string

In the case of the LocalDriver, this is the (relative) path to the file.

Tags

throws
FolderDoesNotExistException

Return values

array

getFolderInFolder()

Returns the Identifier for a folder within a given folder.

public getFolderInFolder(string $folderName, string $folderIdentifier) : string

Parameters

$folderName : string

The name of the target folder

$folderIdentifier : string

Return values

string

getFoldersInFolder()

Returns a list of folders inside the specified path

public getFoldersInFolder(string $folderIdentifier[, int $start = 0 ][, int $numberOfItems = 0 ][, bool $recursive = false ][, array $folderNameFilterCallbacks = [] ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, string>

Parameters

$folderIdentifier : string
$start : int = 0
$numberOfItems : int = 0
$recursive : bool = false
$folderNameFilterCallbacks : array = []

The method callbacks to use for filtering the items

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values

array<string|int, string> —

folder identifiers (where key and value are identical, but int-like identifiers will get converted to int array keys)

getParentFolderIdentifierOfIdentifier()

Returns the identifier of the folder the file resides in

public getParentFolderIdentifierOfIdentifier(string $fileIdentifier) : mixed

Parameters

$fileIdentifier : string

getPermissions()

Returns the permissions of a file/folder as an array (keys r, w) of boolean flags

public getPermissions(string $identifier) : array

Parameters

$identifier : string

Tags

throws
ResourcePermissionsUnavailableException

Return values

array

getPublicUrl()

Returns the public URL to a file.

public getPublicUrl(string $identifier) : string|null

For the local driver, this will always return a path relative to public web path.

Parameters

$identifier : string

Return values

string|null —

NULL if file is missing or deleted, the generated url otherwise

getRole()

Returns the role of an item (currently only folders; can later be extended for files as well)

public getRole(string $folderIdentifier) : string

Parameters

$folderIdentifier : string

Return values

string

getRootLevelFolder()

Returns the Identifier of the root level folder of the storage.

public getRootLevelFolder() : string

Return values

string

getSpecificFileInformation()

Extracts a specific FileInformation from the FileSystems.

public getSpecificFileInformation(string $fileIdentifier, string $containerPath, string $property) : bool|int|string

Parameters

$fileIdentifier : string
$containerPath : string
$property : string

Tags

throws
InvalidArgumentException

Return values

bool|int|string

hasCapability()

Returns TRUE if this driver has the given capability.

public hasCapability(int $capability) : bool

Parameters

$capability : int

A capability, as defined in a CAPABILITY_* constant

Return values

bool

hash()

Creates a (cryptographic) hash for a file.

public hash(string $fileIdentifier, string $hashAlgorithm) : string

Parameters

$fileIdentifier : string
$hashAlgorithm : string

The hash algorithm to use

Tags

throws
RuntimeException
throws
InvalidArgumentException

Return values

string

hashIdentifier()

Hashes a file identifier, taking the case sensitivity of the file system into account. This helps mitigating problems with case-insensitive databases.

public hashIdentifier(string $identifier) : string

Parameters

$identifier : string

Return values

string

initialize()

Initializes this object. This is called by the storage after the driver has been attached.

public initialize() : mixed

isCaseSensitiveFileSystem()

Returns TRUE if this driver uses case-sensitive identifiers. NOTE: This is a configurable setting, but the setting does not change the way the underlying file system treats the identifiers; the setting should therefore always reflect the file system and not try to change its behaviour

public isCaseSensitiveFileSystem() : bool

Return values

bool

isFolderEmpty()

Checks if a folder contains files and (if supported) other folders.

public isFolderEmpty(string $folderIdentifier) : bool

Parameters

$folderIdentifier : string

Return values

bool —

TRUE if there are no files and folders within $folder

isWithin()

Checks if a given identifier is within a container, e.g. if a file or folder is within another folder. It will also return TRUE if both canonicalized identifiers are equal.

public isWithin(string $folderIdentifier, string $identifier) : bool

Parameters

$folderIdentifier : string
$identifier : string

identifier to be checked against $folderIdentifier

Return values

bool —

TRUE if $content is within or matches $folderIdentifier

mergeConfigurationCapabilities()

Merges the capabilities merged by the user at the storage configuration into the actual capabilities of the driver and returns the result.

public mergeConfigurationCapabilities(int $capabilities) : int

Parameters

$capabilities : int

Return values

int

moveFileWithinStorage()

Moves a file *within* the current storage.

public moveFileWithinStorage(string $fileIdentifier, string $targetFolderIdentifier, string $newFileName) : string

Note that this is only about an inner-storage move action, where a file is just moved to another folder in the same storage.

Parameters

$fileIdentifier : string
$targetFolderIdentifier : string
$newFileName : string

Tags

throws
RuntimeException

Return values

string

moveFolderWithinStorage()

Folder equivalent to moveFileWithinStorage().

public moveFolderWithinStorage(string $sourceFolderIdentifier, string $targetFolderIdentifier, string $newFolderName) : array

Parameters

$sourceFolderIdentifier : string
$targetFolderIdentifier : string
$newFolderName : string

Tags

throws
RuntimeException

Return values

array —

A map of old to new file identifiers

processConfiguration()

Processes the configuration for this driver.

public processConfiguration() : mixed

renameFile()

Renames a file in this storage.

public renameFile(string $fileIdentifier, string $newName) : string

Parameters

$fileIdentifier : string
$newName : string

The target path (including the file name!)

Tags

throws
ExistingTargetFileNameException
throws
RuntimeException

Return values

string —

The identifier of the file after renaming

renameFolder()

Renames a folder in this storage.

public renameFolder(string $folderIdentifier, string $newName) : array

Parameters

$folderIdentifier : string
$newName : string

Tags

throws
RuntimeException

if renaming the folder failed

Return values

array —

A map of old to new file identifiers of all affected files and folders

replaceFile()

Replaces the contents (and file-specific metadata) of a file object with a local file.

public replaceFile(string $fileIdentifier, string $localFilePath) : bool

Parameters

$fileIdentifier : string
$localFilePath : string

Tags

throws
RuntimeException

Return values

bool —

TRUE if the operation succeeded

sanitizeFileName()

Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' Trailing dots are removed

public sanitizeFileName(string $fileName[, string $charset = 'utf-8' ]) : string

Previously in \TYPO3\CMS\Core\Utility\File\BasicFileUtility::cleanFileName()

Parameters

$fileName : string

Input string, typically the body of a fileName

$charset : string = 'utf-8'

Charset of the a fileName (defaults to utf-8)

Tags

throws
InvalidFileNameException

Return values

string —

Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed

setFileContents()

Sets the contents of a file to the specified value.

public setFileContents(string $fileIdentifier, string $contents) : int

Parameters

$fileIdentifier : string
$contents : string

Tags

throws
RuntimeException

if the operation failed

Return values

int —

The number of bytes written to the file

setStorageUid()

Sets the storage uid the driver belongs to

public setStorageUid(int $storageUid) : mixed

Parameters

$storageUid : int

streamFile()

Stream file using a PSR-7 Response object.

public streamFile(string $identifier, array $properties) : ResponseInterface

Parameters

$identifier : string
$properties : array

Return values

ResponseInterface

applyFilterMethodsToDirectoryItem()

Applies a set of filter methods to a file name to find out if it should be used or not. This is e.g. used by directory listings.

protected applyFilterMethodsToDirectoryItem(array $filterMethods, string $itemName, string $itemIdentifier, string $parentIdentifier) : bool

Parameters

$filterMethods : array

The filter methods to use

$itemName : string
$itemIdentifier : string
$parentIdentifier : string

Tags

throws
RuntimeException

Return values

bool

canonicalizeAndCheckFileIdentifier()

Makes sure the Path given as parameter is valid

protected canonicalizeAndCheckFileIdentifier(string $fileIdentifier) : string

Parameters

$fileIdentifier : string

The file path (including the file name!)

Tags

throws
InvalidPathException

Return values

string

canonicalizeAndCheckFilePath()

Makes sure the Path given as parameter is valid

protected canonicalizeAndCheckFilePath(string $filePath) : string

Parameters

$filePath : string

The file path (including the file name!)

Tags

throws
InvalidPathException

Return values

string

canonicalizeAndCheckFolderIdentifier()

Makes sure the Path given as parameter is valid

protected canonicalizeAndCheckFolderIdentifier(string $folderPath) : string

Parameters

$folderPath : string

The file path (including the file name!)

Return values

string

copyFileToTemporaryPath()

Copies a file to a temporary path and returns that path.

protected copyFileToTemporaryPath(string $fileIdentifier) : string

Parameters

$fileIdentifier : string

Tags

throws
RuntimeException

Return values

string —

The temporary path

createIdentifierMap()

Creates a map of old and new file/folder identifiers after renaming or moving a folder. The old identifier is used as the key, the new one as the value.

protected createIdentifierMap(array $filesAndFolders, string $sourceFolderIdentifier, string $targetFolderIdentifier) : array

Parameters

$filesAndFolders : array
$sourceFolderIdentifier : string
$targetFolderIdentifier : string

Tags

throws
FileOperationErrorException

Return values

array

determineBaseUrl()

Determines the base URL for this driver, from the configuration or the TypoScript frontend object

protected determineBaseUrl() : mixed

extractFileInformation()

Extracts information about a file from the filesystem.

protected extractFileInformation(string $filePath, string $containerPath[, array $propertiesToExtract = [] ]) : array

Parameters

$filePath : string

The absolute path to the file

$containerPath : string

The relative path to the file's container

$propertiesToExtract : array = []

array of properties which should be returned, if empty all will be extracted

Return values

array

getAbsoluteBasePath()

Returns the absolute path of the folder this driver operates on.

protected getAbsoluteBasePath() : string

Return values

string

getAbsolutePath()

Returns the absolute path of a file or folder.

protected getAbsolutePath(string $fileIdentifier) : string

Parameters

$fileIdentifier : string

Tags

throws
InvalidPathException

Return values

string

getDirectoryItemList()

Generic wrapper for extracting a list of items from a path.

protected getDirectoryItemList(string $folderIdentifier, int $start, int $numberOfItems, array $filterMethods[, bool $includeFiles = true ][, bool $includeDirs = true ][, bool $recursive = false ][, string $sort = '' ][, bool $sortRev = false ]) : array<string|int, string>

Parameters

$folderIdentifier : string
$start : int

The position to start the listing; if not set, start from the beginning

$numberOfItems : int

The number of items to list; if set to zero, all items are returned

$filterMethods : array

The filter methods used to filter the directory items

$includeFiles : bool = true
$includeDirs : bool = true
$recursive : bool = false
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Tags

throws
InvalidArgumentException

Return values

array<string|int, string> —

folder identifiers (where key and value are identical, but int-like identifiers will get converted to int array keys)

getRecycleDirectory()

Get the path of the nearest recycler folder of a given $path.

protected getRecycleDirectory(string $path) : string

Return an empty string if there is no recycler folder available.

Parameters

$path : string

Return values

string

getTemporaryPathForFile()

Returns a temporary path for a given file, including the file extension.

protected getTemporaryPathForFile(string $fileIdentifier) : non-empty-string

Parameters

$fileIdentifier : string

Return values

non-empty-string

isAllowedAbsolutePath()

Wrapper for `GeneralUtility::isAllowedAbsPath`, which implicitly invokes `GeneralUtility::validPathStr` (like in `parent::isPathValid`).

protected isAllowedAbsolutePath(string $path) : bool

Parameters

$path : string

Return values

bool

isPathValid()

Wrapper for \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr()

protected isPathValid(string $theFile) : bool

Parameters

$theFile : string

Filepath to evaluate

Tags

see
GeneralUtility::validPathStr()

Return values

bool —

TRUE if no '/', '..' or '' is in the $theFile

isValidFilename()

Checks a fileName for validity. This could be overridden in concrete drivers if they have different file naming rules.

protected isValidFilename(string $fileName) : bool

Parameters

$fileName : string

Return values

bool —

TRUE if file name is valid

recycleFileOrFolder()

Moves a file or folder to the given directory, renaming the source in the process if a file or folder of the same name already exists in the target path.

protected recycleFileOrFolder(string $filePath, string $recycleDirectory) : bool

Parameters

$filePath : string
$recycleDirectory : string

Return values

bool

retrieveFileAndFoldersInPath()

Returns a list with the names of all files and folders in a path, optionally recursive.

protected retrieveFileAndFoldersInPath(string $path[, bool $recursive = false ][, bool $includeFiles = true ][, bool $includeDirs = true ][, string $sort = '' ][, bool $sortRev = false ]) : array

Parameters

$path : string

The absolute path

$recursive : bool = false

If TRUE, recursively fetches files and folders

$includeFiles : bool = true
$includeDirs : bool = true
$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values

array

sortDirectoryEntries()

Sort the directory entries by a certain key

protected sortDirectoryEntries(array $directoryEntries[, string $sort = '' ][, bool $sortRev = false ]) : array

Parameters

$directoryEntries : array

Array of directory entry arrays from retrieveFileAndFoldersInPath()

$sort : string = ''

Property name used to sort the items. Among them may be: '' (empty, no sorting), name, fileext, size, tstamp and rw. If a driver does not support the given property, it should fall back to "name".

$sortRev : bool = false

TRUE to indicate reverse sorting (last to first)

Return values

array —

Sorted entries. Content of the keys is undefined.

On this page