FacturaScripts

FileManager

Class to manage the actions with folders and files.

Table of Contents

DEFAULT_FOLDER_PERMS Default permissions to create new folders 0755
EXCLUDE_FOLDERS Folders to exclude in scanFolder. ['.', '..', '.DS_Store', '.well-known']
createFolder() Create the folder. bool
delTree() Recursive delete directory. bool
extractFromMarkers() Extracts strings from between the BEGIN and END markers in the .htaccess file. array
insertWithMarkers() Inserts an array of strings into a file (.htaccess ), placing it between BEGIN and END markers. bool
notWritableFolders() Returns an array with all not writable folders. array
recurseCopy() Copy all files and folders from $src to $dst bool
scanFolder() Returns an array with files and folders inside given $folder array

Constants

DEFAULT_FOLDER_PERMS

Default permissions to create new folders

mixed $DEFAULT_FOLDER_PERMS = 0755

EXCLUDE_FOLDERS

Folders to exclude in scanFolder.

mixed $EXCLUDE_FOLDERS = ['.', '..', '.DS_Store', '.well-known']

Methods

createFolder()

Create the folder.

public static createFolder( $folder : string [, $recursive : bool = false ] [, $mode : int = self::DEFAULT_FOLDER_PERMS ] ) : bool
Parameters
$folder : string

Path to folder to create

$recursive : bool = false

If needs to be created recursively

$mode : int = self::DEFAULT_FOLDER_PERMS

Perms mode in octal format

Return values
bool

delTree()

Recursive delete directory.

public static delTree( $folder : string ) : bool
Parameters
$folder : string
Return values
bool

extractFromMarkers()

Extracts strings from between the BEGIN and END markers in the .htaccess file.

public static extractFromMarkers( $fileName : string , $marker : string ) : array
Parameters
$fileName : string
$marker : string
Tags
source
Return values
array

An array of strings from a file (.htaccess ) from between BEGIN and END markers.

insertWithMarkers()

Inserts an array of strings into a file (.htaccess ), placing it between BEGIN and END markers.

public static insertWithMarkers( $insertion : array , $fileName : string , $marker : string ) : bool

Replaces existing marked info. Retains surrounding data. Creates file if none exists.

Parameters
$insertion : array

The new content to insert.

$fileName : string

Filename to alter.

$marker : string

The marker to alter.

Tags
source
Return values
bool

True on write success, false on failure.

notWritableFolders()

Returns an array with all not writable folders.

public static notWritableFolders( ) : array
Return values
array

recurseCopy()

Copy all files and folders from $src to $dst

public static recurseCopy( $src : string , $dst : string ) : bool
Parameters
$src : string
$dst : string
Return values
bool

scanFolder()

Returns an array with files and folders inside given $folder

public static scanFolder( $folder : string [, $recursive : bool = false ] [, $exclude : array = self::EXCLUDE_FOLDERS ] ) : array
Parameters
$folder : string
$recursive : bool = false
$exclude : array = self::EXCLUDE_FOLDERS
Return values
array

Search results