Files helper class

access public
package kocuj_internal_lib

 Methods

Check if the selected directory exists and is writable

checkDirWritable(string $dir) : boolean
access public

Parameters

$dir

string

Directory to check

Returns

booleanDirectory exists and is writable (true) or not (false)

Copy files

copyFiles(string $from, string $to, $output, array $attr = array()) : boolean
access public

Parameters

$from

string

Directory from which files should be copied

$to

string

Directory to which files should be copied

$output

$attr

array

Attributes; there are the following keys available: "extlist" (array type; list of files extensions to get), "getdirs" (bool type; if true, directories will be get), "getfiles" (bool type; if true, files will be get), "ignoredirerrors" (bool type; if true, errors during removing the directory will not be set), "ignoreitems" (array type; list of files and directories to ignore; if file or directory has to be ignored also in all subdirectories, it should begin with "*" and "/"), "withsubdirs" (bool type; if true, files are also get from subdirectories) - default: empty

Returns

booleanFiles has been removed correctly (true) or there was an error (false)

Create file

createFile(string $filename, string $content = '') : boolean
access public

Parameters

$filename

string

Filename

$content

string

File content - default: empty

Returns

booleanFile has been created correctly (true) or there was an error (false)

Get files list from directory

getFilesList(string $dir, array $attr = array()) : array
access public

Parameters

$dir

string

Directory

$attr

array

Attributes; there are the following keys available: "extlist" (array type; list of files extensions to get), "getdirs" (bool type; if true, directories will be get), "getfiles" (bool type; if true, files will be get), "ignoreitems" (array type; list of files and directories to ignore; if file or directory has to be ignored also in all subdirectories, it should begin with "*" and "/"), "sort" (bool type; if true, files are sorted), "withsubdirs" (bool type; if true, files are also get from subdirectories) - default: empty

Returns

arrayFiles and subdirectories list; each element contains the following keys: "filename" (string type; file or directory name), "isdir" (bool type: true if it is directory, false if it is file)

Get singleton instance

getInstance() : object
Static
access public

Returns

objectSingleton instance

Get relative path

getRelativePath(string $from, string $to) : string
access public

Parameters

$from

string

From path

$to

string

To path

Returns

stringRelative path

Remove files from directory

removeFiles(string $dir, $output, array $attr = array()) : boolean
access public

Parameters

$dir

string

Directory

$output

$attr

array

Attributes; there are the following keys available: "extlist" (array type; list of files extensions to get), "getdirs" (bool type; if true, directories will be get), "getfiles" (bool type; if true, files will be get), "ignoredirerrors" (bool type; if true, errors during removing the directory will not be set), "ignoreitems" (array type; list of files and directories to ignore; if file or directory has to be ignored also in all subdirectories, it should begin with "*" and "/"), "withsubdirs" (bool type; if true, files are also get from subdirectories) - default: empty

Returns

booleanFiles has been removed correctly (true) or there was an error (false)

Disable cloning of object

__clone() : void
access private

Constructor

__construct() : void
access private

Get files list from directory by reccurence

getFilesListReccurence(string $rootDir, string $subDir, array $attr) : array
access private

Parameters

$rootDir

string

Root directory

$subDir

string

Subdirectory

$attr

array

Attributes; there are the following keys available: "extlist" (array type; list of files extensions to get), "getdirs" (bool type; if true, directories will be get), "getfiles" (bool type; if true, files will be get), "ignoreitems" (array type; list of files and directories to ignore; if file or directory has to be ignored also in all subdirectories, it should begin with "*" and "/"), "sort" (bool type; if true, files are sorted), "withsubdirs" (bool type; if true, files are also get from subdirectories)

Returns

arrayFiles and subdirectories list; each element contains the following keys: "filename" (string type; file or directory name), "isdir" (bool type: true if it is directory, false if it is file)

 Properties

 

Singleton instance

$instance : object

Default

NULL
Static
access private