Documentation

FileSystem

Base class for filesystems

Tags
todo

Implement a driver structure to allow efficient cross FS operations

Create a path helper class to sanitize paths

copyright

Cloudrexx AG

author

Robin Glauser robin.glauser@comvation.com

Thomas Däppen thomas.daeppen@cloudrexx.com

Michael Ritter michael.ritter@cloudrexx.com

subpackage

core_mediasource

Table of Contents

Methods

createDirectory()  : string
Creates a new directory
getFileFromPath()  : File|false
Returns the File instance for a given path
getFileList()  : array<string|int, mixed>
Returns all files withing a given folder (recursively by default)
getLink()  : mixed
isDirectory()  : bool
Tells whether $file is a directory or not
isFile()  : bool
Tells whether $file is not a directory
moveFile()  : string
Moves a file to a new location
readFile()  : string
Reads content from $file
removeFile()  : string
Removes the given file from the OS FS
writeFile()  : mixed
Writes $content to $file, erases all existing content

Methods

createDirectory()

Creates a new directory

public createDirectory(string $path, string $directory) : string
Parameters
$path : string

Path relative to this FS' root

$directory : string

Directory name

Return values
string —

Status message

getFileFromPath()

Returns the File instance for a given path

public getFileFromPath(string $path) : File|false

$path needs to be within this FS' root, otherwise this method will return false.

Parameters
$path : string

Path relative to this FS' root

Return values
File|false —

File instance for $path of false

getFileList()

Returns all files withing a given folder (recursively by default)

public getFileList(string $directory[, bool $recursive = true ][, bool $readonly = false ]) : array<string|int, mixed>

For each file within $directory the following structure is returned: => array( 'datainfo' => array( 'filepath' => , 'name' => , 'size' => <human_readable_size>, 'cleansize' => <size_in_bytes>, 'extension' => , 'preview' => <preview_link>, 'hasPreview' => <has_preview>, 'active' => , 'type' => <file_or_dir>, 'readonly' => , 'thumbnail' => array( => , ... ), ), ) Name of the file without path but including file ending is relative to this FS' root is "Dir" for directories <preview_link> is relative to Cx root or "none" if no preview is available <has_preview> is "1" if a preview is available, "" otherwise is used to highlight a file or folder to the user. Always set to false <file_or_dir> is either "file" or "dir" is "1" if the file or folder is readonly and contain list all available thumbnail sizes is only set for directories and if $recursive is true. It contains the same structure again.

Parameters
$directory : string

Path relative to this FS' root

$recursive : bool = true

(optional) If set to false, recursion is skipped

$readonly : bool = false

Set to TRUE to make all files and folders readonly

Tags
todo

Extension "Dir" could be ambiguous

Sanitize files named "datainfo"

Return values
array<string|int, mixed> —

UTF8 encoded list of file names, see description

isDirectory()

Tells whether $file is a directory or not

public isDirectory(File $file) : bool
Parameters
$file : File

File to check

Return values
bool —

True if $file is a directory, false otherwise

isFile()

Tells whether $file is not a directory

public isFile(File $file) : bool
Parameters
$file : File

File to check

Return values
bool —

True if $file is not a directory, false otherwise

moveFile()

Moves a file to a new location

public moveFile(File $file, string $destination) : string
Parameters
$file : File

File to move

$destination : string

Destination path (absolute or relative to this FS' root)

Tags
todo

Specify whether moving accross FS should be supported by this method

Return values
string —

Status message

readFile()

Reads content from $file

public readFile(File $file) : string
Parameters
$file : File

File to write to

Return values
string —

File contents

removeFile()

Removes the given file from the OS FS

public removeFile(File $file) : string
Parameters
$file : File

File to remove

Return values
string —

Status message

writeFile()

Writes $content to $file, erases all existing content

public writeFile(File $file, string $content) : mixed
Parameters
$file : File

File to write to

$content : string

Content to write

On this page

Search results