class FsUtils (View source)

Methods

static string
getBackupDir(string $subdir = null)

Decide where our backup directory should go

static A
getBackupDirParent()

Get the base dir where our backup directories will be stored. Also stores CLI history file.

static bool|string
isUsableDirectory(string|null $dir)

Determine if the specified location is writable, or if a writable directory could be created at that path.

static string
tmpDir(string $subdir = null)

Prepare a temporary directory that will be deleted on exit.

static 
registerForDeletion(string $dir)

Add the given directory to a list to be deleted on exit.

static 
cleanup()

Delete all of the files registered for deletion.

static string
prepareBackupDir(string $subdir = null)

Prepare a backup directory.

static string
realpath(string $path)

Returns canonicalized absolute pathname.

static string|bool
isTarball(string $path)

Check whether a file is a supported tarball.

static string|bool|null
getMimeContentType(string $path)

Determines the MIME content type of the specified file.

Details

static string getBackupDir(string $subdir = null)

Decide where our backup directory should go

Parameters

string $subdir

The name of the desired subdirectory(s) under drush-backups. Usually a database name.

Return Value

string

path to the backup directory.

Exceptions

Exception

static A getBackupDirParent()

Get the base dir where our backup directories will be stored. Also stores CLI history file.

Return Value

A

path to the backup directory parent

Exceptions

Exception

static bool|string isUsableDirectory(string|null $dir)

Determine if the specified location is writable, or if a writable directory could be created at that path.

Parameters

string|null $dir

Path to directory that we are considering using

Return Value

bool|string

static string tmpDir(string $subdir = null)

Prepare a temporary directory that will be deleted on exit.

Parameters

string $subdir

A string naming the subdirectory of the backup directory.

Return Value

string

Path to the specified backup directory.

Exceptions

Exception

static registerForDeletion(string $dir)

Add the given directory to a list to be deleted on exit.

Parameters

string $dir

Path to directory to be deleted later.

static cleanup()

Delete all of the files registered for deletion.

static string prepareBackupDir(string $subdir = null)

Prepare a backup directory.

Parameters

string $subdir

A string naming the subdirectory of the backup directory.

Return Value

string

Path to the specified backup directory.

Exceptions

Exception

static string realpath(string $path)

Returns canonicalized absolute pathname.

The difference between this and PHP's realpath() is that this will return the original path even if it doesn't exist.

Parameters

string $path

The path being checked.

Return Value

string

The canonicalized absolute pathname.

static string|bool isTarball(string $path)

Check whether a file is a supported tarball.

Parameters

string $path

Return Value

string|bool

The file content type if it's a tarball. FALSE otherwise.

static string|bool|null getMimeContentType(string $path)

Determines the MIME content type of the specified file.

The power of this function depends on whether the PHP installation has either mime_content_type() or finfo installed -- if not, only tar, gz, zip and bzip2 types can be detected.

Parameters

string $path

Return Value

string|bool|null

The MIME content type of the file.