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:
  • $pathstring
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:
  • $pathstring
  • $extensionsstring, array
  • $ignoreCasebool
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:
  • $pathstring
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:
  • $pathstring
  • $checkercallable - (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:
  • $pathstring
  • $onProgresscallable - (File $file, $depth)
  • $maxDepthint - if 0 then unlimited.
  • $subIsFirstbool
static hash($source, $algo = 'MD5')

Calculates hash of file or stream.

Parameters:
  • $sourcestring, php\io\Stream
  • $algostring - MD5, MD2, SHA-1, SHA-256, SHA-512
Returns:

string

static copy($source, $dest, $onProgress = null)

Copies $source stream to $dest stream.

Parameters:
Returns:

int copied bytes.

static get($source, $charset = null, $mode = 'r')

Reads fully data from source and returns it as binary string.

Parameters:
  • $sourcestring
  • $charsetnull, string - UTF-8, windows-1251, etc.
  • $modestring
Returns:

string