class Filesystem (View source)

Methods

__construct(ProcessExecutor $executor = null)

No description

remove($file)

No description

bool
isDirEmpty(string $dir)

Checks if a directory is empty

emptyDirectory($dir, $ensureDirectoryExists = true)

No description

bool
removeDirectory(string $directory)

Recursively remove a directory

bool
removeDirectoryPhp(string $directory)

Recursively delete directory using PHP iterators.

ensureDirectoryExists($directory)

No description

bool
unlink(string $path)

Attempts to unlink a file and in case of failure retries after 350ms on windows

bool
rmdir(string $path)

Attempts to rmdir a file and in case of failure retries after 350ms on windows

copyThenRemove(string $source, string $target)

Copy then delete is a non-atomic version of {@link rename}.

bool
copy($source, $target)

Copies a file or directory from $source to $target.

rename($source, $target)

No description

string
findShortestPath(string $from, string $to, bool $directories = false)

Returns the shortest path from $from to $to

string
findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false)

Returns PHP code that, when executed in $from, will return the path to $to

bool
isAbsolutePath(string $path)

Checks if the given path is absolute

int
size(string $path)

Returns size of a file or directory specified by path. If a directory is given, it's size will be computed recursively.

string
normalizePath(string $path)

Normalize a path. This replaces backslashes with slashes, removes ending slash and collapses redundant separators and up-level references.

static bool
isLocalPath(string $path)

Return if the given path is local

static 
getPlatformPath($path)

No description

directorySize($directory)

No description

getProcess()

No description

bool
relativeSymlink(string $target, string $link)

Creates a relative symlink from $link to $target

bool
isSymlinkedDirectory(string $directory)

return true if that directory is a symlink.

junction(string $target, string $junction)

Creates an NTFS junction.

bool
isJunction(string $junction)

Returns whether the target directory is a Windows NTFS Junction.

bool
removeJunction(string $junction)

Removes a Windows NTFS junction.

Details

__construct(ProcessExecutor $executor = null)

Parameters

ProcessExecutor $executor

remove($file)

Parameters

$file

bool isDirEmpty(string $dir)

Checks if a directory is empty

Parameters

string $dir

Return Value

bool

emptyDirectory($dir, $ensureDirectoryExists = true)

Parameters

$dir
$ensureDirectoryExists

bool removeDirectory(string $directory)

Recursively remove a directory

Uses the process component if proc_open is enabled on the PHP installation.

Parameters

string $directory

Return Value

bool

Exceptions

RuntimeException

bool removeDirectoryPhp(string $directory)

Recursively delete directory using PHP iterators.

Uses a CHILD_FIRST RecursiveIteratorIterator to sort files before directories, creating a single non-recursive loop to delete files/directories in the correct order.

Parameters

string $directory

Return Value

bool

ensureDirectoryExists($directory)

Parameters

$directory

Attempts to unlink a file and in case of failure retries after 350ms on windows

Parameters

string $path

Return Value

bool

Exceptions

RuntimeException

bool rmdir(string $path)

Attempts to rmdir a file and in case of failure retries after 350ms on windows

Parameters

string $path

Return Value

bool

Exceptions

RuntimeException

copyThenRemove(string $source, string $target)

Copy then delete is a non-atomic version of {@link rename}.

Some systems can't rename and also don't have proc_open, which requires this solution.

Parameters

string $source
string $target

bool copy($source, $target)

Copies a file or directory from $source to $target.

Parameters

$source
$target

Return Value

bool

rename($source, $target)

Parameters

$source
$target

string findShortestPath(string $from, string $to, bool $directories = false)

Returns the shortest path from $from to $to

Parameters

string $from
string $to
bool $directories if true, the source/target are considered to be directories

Return Value

string

Exceptions

InvalidArgumentException

string findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false)

Returns PHP code that, when executed in $from, will return the path to $to

Parameters

string $from
string $to
bool $directories if true, the source/target are considered to be directories
bool $staticCode

Return Value

string

Exceptions

InvalidArgumentException

bool isAbsolutePath(string $path)

Checks if the given path is absolute

Parameters

string $path

Return Value

bool

int size(string $path)

Returns size of a file or directory specified by path. If a directory is given, it's size will be computed recursively.

Parameters

string $path Path to the file or directory

Return Value

int

Exceptions

RuntimeException

string normalizePath(string $path)

Normalize a path. This replaces backslashes with slashes, removes ending slash and collapses redundant separators and up-level references.

Parameters

string $path Path to the file or directory

Return Value

string

static bool isLocalPath(string $path)

Return if the given path is local

Parameters

string $path

Return Value

bool

static getPlatformPath($path)

Parameters

$path

protected directorySize($directory)

Parameters

$directory

protected getProcess()

Creates a relative symlink from $link to $target

Parameters

string $target The path of the binary file to be symlinked
string $link The path where the symlink should be created

Return Value

bool

bool isSymlinkedDirectory(string $directory)

return true if that directory is a symlink.

Parameters

string $directory

Return Value

bool

junction(string $target, string $junction)

Creates an NTFS junction.

Parameters

string $target
string $junction

bool isJunction(string $junction)

Returns whether the target directory is a Windows NTFS Junction.

Parameters

string $junction Path to check.

Return Value

bool

bool removeJunction(string $junction)

Removes a Windows NTFS junction.

Parameters

string $junction

Return Value

bool