PHP Class JBZoo\Utils\FS

ファイルを表示 Open project: jbzoo/utils Class Usage Examples

Public Methods

Method 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.

Protected Methods

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

Method Details

_chmod() protected static method

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

_setPerms() protected static method

protected static _setPerms ( string $filename, boolean $isFlag, integer $perm ) : boolean
$filename string
$isFlag boolean
$perm integer
return boolean

base() public static method

public static base ( string $path ) : string
$path string
return string

clean() public static method

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).
return string

dirSize() public static method

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

dirname() public static method

public static dirname ( string $path ) : string
$path string
return string

executable() public static method

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
return boolean

ext() public static method

public static ext ( string $path ) : string
$path string
return string

filename() public static method

public static filename ( string $path ) : string
$path string
return string

firstLine() public static method

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

format() public static method

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
return string

getRelative() public static method

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
return mixed

isDir() public static method

Check is current path directory
public static isDir ( string $path ) : boolean
$path string
return boolean

isFile() public static method

Check is current path regular file
public static isFile ( string $path ) : boolean
$path string
return boolean

isReal() public static method

public static isReal ( $path ) : boolean
$path
return boolean

ls() public static method

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

openFile() public static method

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

perms() public static method

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.
return string

readable() public static method

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
return boolean

real() public static method

public static real ( string $path ) : string
$path string
return string

rmdir() public static method

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
return boolean

stripExt() public static method

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

writable() public static method

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
return boolean