Library
Class

Library\Helper\Directory

class Directory

Directory helper

As for all helpers, all methods are statics.

For convenience, the best practice is to use:

use Library\Helper\Directory as DirectoryHelper;

Constants

DEFAULT_UNIX_CHMOD_DIRECTORIES

DEFAULT_UNIX_CHMOD_FILES

Methods

static string slashDirname(string $dirname = null)

Get a dirname with one and only trailing slash

static bool isGitClone(string $path = null)

Test if a path seems to be a git clone

static bool isDotPath(string $path = null)

Test if a filename seems to have a dot as first character

static bool ensureExists(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true)

Build a directory with its whole hierarchy if necessary

static bool create(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true)

Create a directory if necessary

static bool remove(string $path = null, array $logs = array())

Remove a directory with its whole contents

static bool purge(string $path = null, array $logs = array())

Remove a directory contents but not the directory itself

static bool chmod(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true, int $file_mode = self::DEFAULT_UNIX_CHMOD_FILES, array $logs = array())

Change rights on a directory

Details

at line 56
static public string slashDirname(string $dirname = null)

Get a dirname with one and only trailing slash

Parameters

string $dirname

Return Value

string

at line 70
static public bool isGitClone(string $path = null)

Test if a path seems to be a git clone

Parameters

string $path

Return Value

bool

at line 85
static public bool isDotPath(string $path = null)

Test if a filename seems to have a dot as first character

Parameters

string $path

Return Value

bool

at line 105
static public bool ensureExists(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true)

Build a directory with its whole hierarchy if necessary

Parameters

string $path
int $mode
bool $recursive

Return Value

bool

at line 124
static public bool create(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true)

Create a directory if necessary

Parameters

string $path
int $mode
bool $recursive

Return Value

bool

at line 139
static public bool remove(string $path = null, array $logs = array())

Remove a directory with its whole contents

Parameters

string $path
array $logs Logs registry passed by reference

Return Value

bool

at line 181
static public bool purge(string $path = null, array $logs = array())

Remove a directory contents but not the directory itself

Parameters

string $path
array $logs Logs registry passed by reference

Return Value

bool

at line 227
static public bool chmod(string $path = null, int $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES, bool $recursive = true, int $file_mode = self::DEFAULT_UNIX_CHMOD_FILES, array $logs = array())

Change rights on a directory

Parameters

string $path
int $mode
bool $recursive
int $file_mode
array $logs Logs registry passed by reference

Return Value

bool