A generic file object.

package filicious-core
author Christian Schiffler
author Tristan Lins
author Oliver Hoff

 Methods

__construct()

__construct(\Filicious\Internals\Pathname $pathname) 

Parameters

Return a stream url or pathname, if streaming is not supported.

__toString() : string
see

Returns

string

Append contents to the file.

appendContents(string $content, bool $create) : \Filicious\File
API
api

Parameters

$content

string

$create

bool

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Copy this file to another destination.

copyTo(\Filicious\File $destination, bool $recursive, int $overwrite, bool $createParents) : \Filicious\File
API
api

Parameters

$destination

\Filicious\File

The target destination.

$recursive

bool

$overwrite

int

$createParents

bool

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Count all children of this directory.

count(int|string|\Closure|callable $filter, $_) : int
API
api

Parameters

$filter

intstring\Closurecallable

Variable list of filters. - Flags File::LIST_* - Glob pattern - Callables

$_

Exceptions

\Filicious\Exception\NotADirectoryException

Returns

int

Create a new directory.

createDirectory(bool $createParents) : \Filicious\File
API
api

Parameters

$createParents

bool

Returns

Create an empty file.

createFile(bool $createParents) : \Filicious\File
API
api

Parameters

$createParents

bool

Returns

Delete a file or directory.

delete(bool $recursive, bool $force) : \Filicious\File
API
api

Parameters

$recursive

bool

$force

bool

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Check if file exists.

exists() : bool
API
api

Returns

bool

Returns the date and time at which the file was accessed last time.

getAccessTime() : \DateTime
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

\DateTimeThe last access time

Returns the basename of this file, which is the string after the last forward slash of the pathname of this file.

getBasename(string $suffix) : string
API
If the basename ends with the given suffix, it will be truncated off of the end of the basename.
api

Parameters

$suffix

string

The suffix to truncate

Returns

stringThe basename

Get contents of the file.

getContents() : string
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

string

Returns the date and time at which the file was created.

getCreationTime() : \DateTime
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

\DateTimeThe creation time

Return the dirname or parent name.

getDirname() : string
API
api

Returns

string

Return the extension of the filename.

getExtension() : string
API
May return an empty string, if filename has no extension.
api

Returns

string

Get the filesystem this file belongs to.

getFilesystem() : \Filicious\Filesystem
API
api

Returns

Return the group of the file.

getGroup() : int | string
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

intstring

Get an iterator for this directory.

getIterator(int|string|\Closure|callable $filter, $_) : \Iterator
API
api

Parameters

$filter

intstring\Closurecallable

Variable list of filters. - Flags File::LIST_* - Glob pattern - Callables

$_

Returns

Return the permission mode of the file.

getMode() : int
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

int

Returns the time at which the file was modified last time.

getModifyTime() : \DateTime
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

\DateTimeThe modify time

Return the owner of the file.

getOwner() : int | string
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

intstring

Return the parent file object.

getParent() : \Filicious\File | null
API
May return null if called on the root "/" node.
api

Returns

Returns the full abstracted pathname of this file within the containing filesystem.

getPathname() : string
API
A pathname always starts with a forward slash and never ends with one. The exception is the root of the filesystem, which returns the empty string.
api

Returns

stringThe full abstracted pathname

Return a plugin for the filesystem.

getPlugin(string $name) : \Filicious\Plugin\FilePluginInterface | null
API
api

Parameters

$name

string

Returns

Returns the size of the file.

getSize($recursive) : int
API
api

Parameters

$recursive

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

intThe file size

Get a stream object to the file.

getStream() : \Filicious\Stream
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists
\Filicious\Exception\NotAFileException If the pathname is not a file.

Returns

Get a streaming url to the file.

getStreamURL() : string
API
api

Returns

string

Return a plugin for the filesystem.

hasPlugin(string $name) : bool
API
api

Parameters

$name

string

Returns

bool

INTERNAL USE ONLY

internalPathname() : \Filicious\Internals\Pathname
internal Used to access the internal API. This is formally used within adapters or plugins.

Returns

Checks if the file is a directory.

isDirectory() : bool
API
api

Returns

boolTrue if the file exists and is a directory; otherwise false

Check if file is executable.

isExecutable() : bool
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

bool

Checks if the file is a file.

isFile() : bool
API
api

Returns

boolTrue if the file exists and is a file; otherwise false

Check if file is readable.

isReadable() : bool
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

bool

Check if file is writable.

isWritable() : bool
API
api

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

bool

List all children of this directory.

ls(int|string|\Closure|callable $filter, $_) : \Filicious\File[]
API
api

Parameters

$filter

intstring\Closurecallable

Variable list of filters. - Flags File::LIST_* - Glob pattern - Callables

$_

Exceptions

\Filicious\Exception\NotADirectoryException

Returns

Move this file to another destination.

moveTo(\Filicious\File $destination, int $overwrite, bool $createParents) : \Filicious\File
API
api

Parameters

$destination

\Filicious\File

The target destination.

$overwrite

int

$createParents

bool

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Set the date and time at which the file was accessed last time.

setAccessTime(int|string|\DateTime $accessTime) : \Filicious\File
API
The given $accessTime parameter is converted to a \DateTime object via Util::createDateTime.
api

Parameters

$accessTime

intstring\DateTime

The new access time

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Set contents of the file.

setContents(string $content, bool $create) : \Filicious\File
API
api

Parameters

$content

string

$create

bool

Exceptions

\Filicious\Exception\NotAFileException If the pathname is not a file.

Returns

Set the group of the file.

setGroup(string|int $group) : \Filicious\File
API
api

Parameters

$group

stringint

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Set the permission mode of the file.

setMode(int $mode) : \Filicious\File
API
api

Parameters

$mode

int

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Set the date and time at which the file was modified last time.

setModifyTime(int|string|\DateTime $modifyTime) : static
API
The given $modifyTime parameter is converted to a \DateTime object via Util::createDateTime.
api

Parameters

$modifyTime

intstring\DateTime

The new modify time

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

static

Set the owner of the file.

setOwner(string|int $user) : \Filicious\File
API
api

Parameters

$user

stringint

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists

Returns

Set the date and time at which the file was modified and / or accessed last time.

touch(int|string|\DateTime $modifyTime, int|string|\DateTime $accessTime, bool $create) : void
API
The given $time and $atime parameters are converted to \DateTime objects via Util::createDateTime, with the one exception, that if $atime parameter is set to null, then the date and time given in the $time parameter will be used for $atime.
api

Parameters

$modifyTime

intstring\DateTime

The new modify time

$accessTime

intstring\DateTime

The new access time; If null then $time will be used

$create

bool

Whether to create the file, if it does not already exists

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists and $create is set to false

Truncate file to a given size.

truncate(int $size) : static
API
api

Parameters

$size

int

Exceptions

\Filicious\Exception\FileNotFoundException If the file does not exists
\Filicious\Exception\NotAFileException If the pathname is not a file.

Returns

static

 Properties

 

$filesystem

$filesystem : \Filicious\Filesystem
 

$pathname

$pathname : \Filicious\Internals\Pathname

 Constants

 

List everything (LIST_HIDDEN | LIST_VISIBLE | LIST_FILES | LIST_DIRECTORIES | LIST_LINKS | LIST_OPAQUE)

LIST_ALL 
API
api
 

Return only directories.

LIST_DIRECTORIES 
API
api
 

Return only files.

LIST_FILES 
API
api
 

Return hidden files (starting with ".")

LIST_HIDDEN 
API
api
   

List non-links.

LIST_OPAQUE 
API
api
 

List recursive.

LIST_RECURSIVE 
API
api
 

Return non-hidden (not starting with ".")

LIST_VISIBLE 
API
api
 

<p>Flag for file operations, which involve a file target destination, to merge the operations file source with the operations file target destination.</p>

OPERATION_MERGE : int
API
api
 

<p>Flag for file operations, which involve a file target destination, indicating that missing parent directories of the operations file target destination should be created before the execution of the operation is done</p>

OPERATION_PARENTS : int
API
api
 

<p>Flag for file operations to apply the execution recrusivly, if the file being operated on is a directory.</p>

OPERATION_RECURSIVE : int
API
api
 

<p>Flag for file operations, which involve a file target destination, to reject the execution of the operation, if the operations file target destination already exists. This flag overrules the OPERATION_REPLACE flag.</p>

OPERATION_REJECT : int
API
api
 

<p>Flag for file operations, which involve a file target destination, to replace the target destination.</p>

OPERATION_REPLACE : int
API
api