PHP Class AppserverIo\Appserver\Core\Utilities\FileSystem

Show file Open project: appserver-io/appserver Class Usage Examples

Public Methods

Method Description
chmod ( string $path, integer $perm ) : boolean Chmod function
chown ( string $path, integer $user, integer | null $group = null ) : boolean Chown function
cleanUpDir ( SplFileInfo $dir, boolean $alsoRemoveFiles = true ) : void Deletes all files and subdirectories from the passed directory.
copyDir ( string $src, string $dst ) : void Copies a directory recursively.
createDirectory ( string $directoryToCreate, integer $mode = 509, boolean $recursive = false ) : void Creates the passed directory.
getOsIdentifier ( ) : string Will return a three character OS identifier e.g. WIN or LIN
globDir ( string $pattern, integer $flags, boolean $recursive = true ) : array Parses and returns the directories and files that matches the passed glob pattern in a recursive way (if wanted).
initUmask ( integer $umask ) : void Init the umask to use creating files/directories, either with the passed value or the one found in the configuration.
recursiveChmod ( string $path, integer $filePerm = 420, integer $dirPerm = 493 ) : void Chmods files and folders with different permissions.
recursiveChown ( string $path, string $user, string $group = null ) : void Will set the owner and group on the passed directory.
removeDir ( string $src ) : void Removes a directory recursively.

Method Details

chmod() public static method

Chmod function
public static chmod ( string $path, integer $perm ) : boolean
$path string Relative or absolute path to a file or directory which should be processed.
$perm integer The permissions any file or dir should get.
return boolean

chown() public static method

Chown function
public static chown ( string $path, integer $user, integer | null $group = null ) : boolean
$path string Relative or absolute path to a file or directory which should be processed.
$user integer The user that should gain owner rights.
$group integer | null The group that should gain group rights.
return boolean

cleanUpDir() public static method

Deletes all files and subdirectories from the passed directory.
public static cleanUpDir ( SplFileInfo $dir, boolean $alsoRemoveFiles = true ) : void
$dir SplFileInfo The directory to remove
$alsoRemoveFiles boolean The flag for removing files also
return void

copyDir() public static method

Copies a directory recursively.
public static copyDir ( string $src, string $dst ) : void
$src string The source directory to copy
$dst string The target directory
return void

createDirectory() public static method

Creates the passed directory.
public static createDirectory ( string $directoryToCreate, integer $mode = 509, boolean $recursive = false ) : void
$directoryToCreate string The directory that should be created
$mode integer The mode to create the directory with
$recursive boolean TRUE if the directory has to be created recursively, else FALSE
return void

getOsIdentifier() public static method

Will return a three character OS identifier e.g. WIN or LIN
public static getOsIdentifier ( ) : string
return string

globDir() public static method

Parses and returns the directories and files that matches the passed glob pattern in a recursive way (if wanted).
public static globDir ( string $pattern, integer $flags, boolean $recursive = true ) : array
$pattern string The glob pattern used to parse the directories
$flags integer The flags passed to the glob function
$recursive boolean Whether or not to parse directories recursively
return array The directories matches the passed glob pattern

initUmask() public static method

Init the umask to use creating files/directories, either with the passed value or the one found in the configuration.
public static initUmask ( integer $umask ) : void
$umask integer The new umask to set
return void

recursiveChmod() public static method

This is an all-PHP alternative to using: \n exec("find ".$path." -type f -exec chmod 644 } \;"); \n exec("find ".$path." -type d -exec chmod 755 } \;");
public static recursiveChmod ( string $path, integer $filePerm = 420, integer $dirPerm = 493 ) : void
$path string Relative or absolute path to a file or directory which should be processed.
$filePerm integer The permissions any found files should get.
$dirPerm integer The permissions any found folder should get.
return void

recursiveChown() public static method

Will set the owner and group on the passed directory.
public static recursiveChown ( string $path, string $user, string $group = null ) : void
$path string The directory to set the rights for
$user string The user to set
$group string The group to set
return void

removeDir() public static method

Removes a directory recursively.
public static removeDir ( string $src ) : void
$src string The source directory to be removed
return void