PHP Class JBZoo\Utils\FS

Afficher le fichier Open project: jbzoo/utils Class Usage Examples

Méthodes publiques

Méthode Description
base ( string $path ) : string
clean ( string $path, string $dirSep = DIRECTORY_SEPARATOR ) : string Function to strip additional / or \ in a path name.
dirSize ( string $dir ) : integer Returns size of a given directory in bytes.
dirname ( string $path ) : string
executable ( string $filename, boolean $executable = true ) : boolean Set the executable bit on a file to the minimum value that allows the user running PHP to read to it.
ext ( string $path ) : string
filename ( string $path ) : string
firstLine ( string $filepath ) : string Quickest way for getting first file line
format ( integer $bytes, integer $decimals = 2 ) : string Nice formatting for computer sizes (Bytes).
getRelative ( string $filePath, string | null $rootPath = null, string $forceDS = DIRECTORY_SEPARATOR, boolean $toRealpath = true ) : mixed Find relative path of file (remove root part)
isDir ( string $path ) : boolean Check is current path directory
isFile ( string $path ) : boolean Check is current path regular file
isReal ( $path ) : boolean
ls ( string $dir ) : array Returns all paths inside a directory.
openFile ( $filepath ) : null | string Binary safe to open file
perms ( string $file, integer $perms = null ) : string Returns the file permissions as a nice string, like -rw-r--r-- or false if the file is not found.
readable ( string $filename, boolean $readable = true ) : boolean Set the readable bit on a file to the minimum value that allows the user running PHP to read to it.
real ( string $path ) : string
rmdir ( string $dir, boolean $traverseSymlinks = false ) : boolean Removes a directory (and its contents) recursively.
stripExt ( string $path ) : string Strip off the extension if it exists.
writable ( string $filename, boolean $writable = true ) : boolean Set the writable bit on a file to the minimum value that allows the user running PHP to write to it.

Méthodes protégées

Méthode Description
_chmod ( string $filename, integer $perm, integer $add ) : boolean Chmod alias
_setPerms ( string $filename, boolean $isFlag, integer $perm ) : boolean

Method Details

_chmod() protected static méthode

Chmod alias
protected static _chmod ( string $filename, integer $perm, integer $add ) : boolean
$filename string
$perm integer
$add integer
Résultat boolean

_setPerms() protected static méthode

protected static _setPerms ( string $filename, boolean $isFlag, integer $perm ) : boolean
$filename string
$isFlag boolean
$perm integer
Résultat boolean

base() public static méthode

public static base ( string $path ) : string
$path string
Résultat string

clean() public static méthode

Function to strip additional / or \ in a path name.
public static clean ( string $path, string $dirSep = DIRECTORY_SEPARATOR ) : string
$path string The path to clean.
$dirSep string Directory separator (optional).
Résultat string

dirSize() public static méthode

Returns size of a given directory in bytes.
public static dirSize ( string $dir ) : integer
$dir string
Résultat integer

dirname() public static méthode

public static dirname ( string $path ) : string
$path string
Résultat string

executable() public static méthode

Set the executable bit on a file to the minimum value that allows the user running PHP to read to it.
public static executable ( string $filename, boolean $executable = true ) : boolean
$filename string The filename to set the executable bit on
$executable boolean Whether to make the file executable or not
Résultat boolean

ext() public static méthode

public static ext ( string $path ) : string
$path string
Résultat string

filename() public static méthode

public static filename ( string $path ) : string
$path string
Résultat string

firstLine() public static méthode

Quickest way for getting first file line
public static firstLine ( string $filepath ) : string
$filepath string
Résultat string

format() public static méthode

Nice formatting for computer sizes (Bytes).
public static format ( integer $bytes, integer $decimals = 2 ) : string
$bytes integer The number in bytes to format
$decimals integer The number of decimal points to include
Résultat string

getRelative() public static méthode

Find relative path of file (remove root part)
public static getRelative ( string $filePath, string | null $rootPath = null, string $forceDS = DIRECTORY_SEPARATOR, boolean $toRealpath = true ) : mixed
$filePath string
$rootPath string | null
$forceDS string
$toRealpath boolean
Résultat mixed

isDir() public static méthode

Check is current path directory
public static isDir ( string $path ) : boolean
$path string
Résultat boolean

isFile() public static méthode

Check is current path regular file
public static isFile ( string $path ) : boolean
$path string
Résultat boolean

isReal() public static méthode

public static isReal ( $path ) : boolean
$path
Résultat boolean

ls() public static méthode

Returns all paths inside a directory.
public static ls ( string $dir ) : array
$dir string
Résultat array

openFile() public static méthode

Binary safe to open file
public static openFile ( $filepath ) : null | string
$filepath
Résultat null | string

perms() public static méthode

Returns the file permissions as a nice string, like -rw-r--r-- or false if the file is not found.
public static perms ( string $file, integer $perms = null ) : string
$file string The name of the file to get permissions form
$perms integer Numerical value of permissions to display as text.
Résultat string

readable() public static méthode

Set the readable bit on a file to the minimum value that allows the user running PHP to read to it.
public static readable ( string $filename, boolean $readable = true ) : boolean
$filename string The filename to set the readable bit on
$readable boolean Whether to make the file readable or not
Résultat boolean

real() public static méthode

public static real ( string $path ) : string
$path string
Résultat string

rmdir() public static méthode

Contributed by Askar (ARACOOL)
public static rmdir ( string $dir, boolean $traverseSymlinks = false ) : boolean
$dir string The directory to be deleted recursively
$traverseSymlinks boolean Delete contents of symlinks recursively
Résultat boolean

stripExt() public static méthode

Strip off the extension if it exists.
public static stripExt ( string $path ) : string
$path string
Résultat string

writable() public static méthode

Set the writable bit on a file to the minimum value that allows the user running PHP to write to it.
public static writable ( string $filename, boolean $writable = true ) : boolean
$filename string The filename to set the writable bit on
$writable boolean Whether to make the file writable or not
Résultat boolean