fs¶
-
php\lib\fs
File System class.
Class fs
Methods
- static
separator
¶Return the local filesystem’s name-separator character.
Returns: string
- static
pathSeparator
¶Return the local filesystem’s path-separator character.
Returns: string
- static
valid
($name)¶Validate file name.
Parameters:
- $name –
Returns: bool
- static
abs
($path)¶Returns absolute real path.
Parameters:
- $path –
Returns: string
- static
name
($path)¶
Parameters:
- $path –
Returns: string
- static
nameNoExt
($path)¶
Parameters:
- $path –
Returns: string
- static
pathNoExt
($path)¶Returns path without extension.
Parameters:
- $path – string
Returns: string
- static
ext
($path)¶Returns extension of path.
Parameters:
- $path –
Returns: string
- static
hasExt
($path, $extensions = null, $ignoreCase = true)¶Check that $path has an extension from the extension set.
Parameters:
- $path – string
- $extensions – string, array
- $ignoreCase – bool
Returns: bool
- static
parent
($path)¶Returns parent directory.
Parameters:
- $path –
Returns: string
- static
ensureParent
($path)¶Checks parent of path and if it is not exists, tries to create parent directory. See makeDir().
Parameters:
- $path – string
Returns: bool
- static
normalize
($path)¶Normalizes file path for current OS.
Parameters:
- $path –
Returns: string
- static
exists
($path)¶
Parameters:
- $path –
Returns: string
- static
size
($path)¶Returns size of file in bytes.
Parameters:
- $path –
Returns: int
- static
isFile
($path)¶
Parameters:
- $path –
Returns: bool
- static
isDir
($path)¶
Parameters:
- $path –
Returns: bool
- static
isHidden
($path)¶
Parameters:
- $path –
Returns: bool
- static
time
($path)¶Returns last modification time of file or directory.
Parameters:
- $path –
Returns: int
- static
makeDir
($path)¶Creates empty directory (mkdirs) if not exists.
Parameters:
- $path –
Returns: bool
- static
makeFile
($path)¶Creates empty file, if file already exists then rewrite it.
Parameters:
- $path –
Returns: bool
- static
delete
($path)¶Deletes file or empty directory.
Parameters:
- $path –
Returns: bool
- static
clean
($path, $checker = null)¶Deletes all files in path. This method does not delete the $path directory. Returns array with error, success and skip file list.
Parameters:
- $path – string
- $checker – callable - (File $file, $depth) optional, must return true to delete the file.
Returns: array [success => [], error => [], skip = []]
- static
scan
($path, $onProgress, $maxDepth = 0, $subIsFirst = false)¶
Parameters:
- $path – string
- $onProgress – callable - (File $file, $depth)
- $maxDepth – int - if 0 then unlimited.
- $subIsFirst – bool
- static
hash
($source, $algo = 'MD5')¶Calculates hash of file or stream.
Parameters:
- $source – string, php\io\Stream
- $algo – string - MD5, MD2, SHA-1, SHA-256, SHA-512
Returns: string
- static
copy
($source, $dest, $onProgress = null)¶Copies $source stream to $dest stream.
Parameters:
- $source – string, php\io\File, php\io\Stream
- $dest – string, php\io\File, php\io\Stream
- $onProgress – callable - ($copiedBytes)
Returns: int copied bytes.
- static
get
($source, $charset = null, $mode = 'r')¶Reads fully data from source and returns it as binary string.
Parameters:
- $source – string
- $charset – null, string - UTF-8, windows-1251, etc.
- $mode – string
Returns: string