October\Rain\Filesystem\Filesystem

Extends:

  • Illuminate\Filesystem\Filesystem

Filesystem helper

Public properties

public string $filePermissions

Default file permission mask as a string ("777").

public string $folderPermissions

Default folder permission mask as a string ("777").

public array $pathSymbols

Known path symbols and their prefixes.

Protected properties

protected array|null $symlinkRootCache

A cache of symlinked root directories.

Show inherited protected properties

Inherited protected properties

  • protected static array $macros - defined in Illuminate\Filesystem\Filesystem. The registered string macros.

Public methods

public void chmod(string $path, octal $mask=NULL)

chmod modifies file/folder permissions

Parameters
  • string $path
  • octal $mask

public void chmodRecursive(string $path, octal $fileMask=NULL, octal $directoryMask=NULL)

chmodRecursive modifies file/folder permissions recursively

Parameters
  • string $path
  • octal $fileMask
  • octal $directoryMask

public bool copy(string $path, string $target)

copy a file to a new location.

Parameters
  • string $path
  • string $target

public mixed existsInsensitive(string $path)

existsInsensitive determines if a file exists with case insensitivity supported for the file only.

Parameters
  • string $path

public bool fileNameMatch(string|array $fileName, string $pattern)

fileNameMatch matches filename against a pattern

Parameters
  • string|array $fileName
  • string $pattern

public string fromClass(mixed $className)

fromClass finds the path to a class

Parameters
  • mixed $className - Class name or object

public string getFilePermissions()

getFilePermissions returns the default file permission mask to use

public string getFolderPermissions()

getFolderPermissions returns the default folder permission mask to use

public void getSafe($path, $limitKbs=1)

getSafe reads the first portion of file contents

Parameters
  • $path
  • $limitKbs

public bool isDirectoryEmpty(string $directory)

isDirectoryEmpty determines if the given path contains no files

Parameters
  • string $directory

public boolean isLocalPath(string $path, boolean $realpath=true)

isLocalPath returns true if the specified path is within the path of the application

Parameters
  • string $path - The path to
  • boolean $realpath - Default true, uses realpath() to resolve the provided path before checking location. Set to false if you need to check if a potentially non-existent path would be within the application path

public boolean isPathSymbol(string $path)

isPathSymbol returns true if the path uses a symbol

Parameters
  • string $path

public string localToPublic(string $path)

localToPublic returns a public file path from an absolute one eg: /home/mysite/public_html/welcome -> /welcome

Parameters
  • string $path - Absolute path

public bool makeDirectory(string $path, int $mode=511, bool $recursive=false, bool $force=false)

makeDirectory creates a directory

Parameters
  • string $path
  • int $mode
  • bool $recursive
  • bool $force

public string normalizePath(string $path)

normalizePath normalizes the directory separator, often used by Win systems

Parameters
  • string $path - Path name

public int put(string $path, string $contents, $lock=false)

put writes the contents of a file

Parameters
  • string $path
  • string $contents
  • $lock

public string searchDirectory(string $file, string $directory, $rootDir='')

searchDirectory locates a file and return its relative path Eg: Searching directory /home/mysite for file index.php could locate this file /home/mysite/public_html/welcome/index.php and would return public_html/welcome

Parameters
  • string $file - Index.php
  • string $directory - /home/mysite
  • $rootDir

public string sizeToString(int $bytes)

sizeToString converts a file size in bytes to human readable format

Parameters
  • int $bytes

public string symbolizePath(string $path, mixed $default=false)

symbolizePath converts a path using path symbol. Returns the original path if no symbol is used and no default is specified.

Parameters
  • string $path
  • mixed $default

Show inherited public methods

Inherited public methods

  • public mixed __call(string $method, array $parameters) - defined in Illuminate\Filesystem\Filesystem. Dynamically handle calls to the class.
  • public static mixed __callStatic(string $method, array $parameters) - defined in Illuminate\Filesystem\Filesystem. Dynamically handle calls to the class.
  • public Symfony\Component\Finder\SplFileInfo[] allFiles(string $directory, bool $hidden=false) - defined in Illuminate\Filesystem\Filesystem. Get all of the files from the given directory (recursive).
  • public int append(string $path, string $data) - defined in Illuminate\Filesystem\Filesystem. Append to a file.
  • public string basename(string $path) - defined in Illuminate\Filesystem\Filesystem. Extract the trailing name component from a file path.
  • public bool cleanDirectory(string $directory) - defined in Illuminate\Filesystem\Filesystem. Empty the specified directory of all files and folders.
  • public bool copyDirectory(string $directory, string $destination, int|null $options=NULL) - defined in Illuminate\Filesystem\Filesystem. Copy a directory from one location to another.
  • public bool delete(string|array $paths) - defined in Illuminate\Filesystem\Filesystem. Delete the file at a given path.
  • public bool deleteDirectories(string $directory) - defined in Illuminate\Filesystem\Filesystem. Remove all of the directories within a given directory.
  • public bool deleteDirectory(string $directory, bool $preserve=false) - defined in Illuminate\Filesystem\Filesystem. Recursively delete a directory.
  • public array directories(string $directory) - defined in Illuminate\Filesystem\Filesystem. Get all of the directories within a given directory.
  • public string dirname(string $path) - defined in Illuminate\Filesystem\Filesystem. Extract the parent directory from a file path.
  • public void ensureDirectoryExists(string $path, int $mode=493, bool $recursive=true) - defined in Illuminate\Filesystem\Filesystem. Ensure a directory exists.
  • public bool exists(string $path) - defined in Illuminate\Filesystem\Filesystem. Determine if a file or directory exists.
  • public string extension(string $path) - defined in Illuminate\Filesystem\Filesystem. Extract the file extension from a file path.
  • public Symfony\Component\Finder\SplFileInfo[] files(string $directory, bool $hidden=false) - defined in Illuminate\Filesystem\Filesystem. Get an array of all files in a directory.
  • public string get(string $path, bool $lock=false) - defined in Illuminate\Filesystem\Filesystem. Get the contents of a file.
  • public mixed getRequire(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the returned value of a file.
  • public array glob(string $pattern, int $flags=0) - defined in Illuminate\Filesystem\Filesystem. Find path names matching a given pattern.
  • public static bool hasMacro(string $name) - defined in Illuminate\Filesystem\Filesystem. Checks if macro is registered.
  • public string hash(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the MD5 hash of the file at the given path.
  • public bool isDirectory(string $directory) - defined in Illuminate\Filesystem\Filesystem. Determine if the given path is a directory.
  • public bool isFile(string $file) - defined in Illuminate\Filesystem\Filesystem. Determine if the given path is a file.
  • public bool isReadable(string $path) - defined in Illuminate\Filesystem\Filesystem. Determine if the given path is readable.
  • public bool isWritable(string $path) - defined in Illuminate\Filesystem\Filesystem. Determine if the given path is writable.
  • public int lastModified(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the file's last modification time.
  • public void link(string $target, string $link) - defined in Illuminate\Filesystem\Filesystem. Create a symlink to the target file or directory. On Windows, a hard link is created if the target is a file.
  • public static void macro(string $name, object|callable $macro) - defined in Illuminate\Filesystem\Filesystem. Register a custom macro.
  • public string|false mimeType(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the mime-type of a given file.
  • public bool missing(string $path) - defined in Illuminate\Filesystem\Filesystem. Determine if a file or directory is missing.
  • public static void mixin(object $mixin, bool $replace=true) - defined in Illuminate\Filesystem\Filesystem. Mix another object into the class.
  • public bool move(string $path, string $target) - defined in Illuminate\Filesystem\Filesystem. Move a file to a new location.
  • public bool moveDirectory(string $from, string $to, bool $overwrite=false) - defined in Illuminate\Filesystem\Filesystem. Move a directory.
  • public string name(string $path) - defined in Illuminate\Filesystem\Filesystem. Extract the file name from a file path.
  • public int prepend(string $path, string $data) - defined in Illuminate\Filesystem\Filesystem. Prepend to a file.
  • public void replace(string $path, string $content) - defined in Illuminate\Filesystem\Filesystem. Write the contents of a file, replacing it atomically if it already exists.
  • public mixed requireOnce(string $file) - defined in Illuminate\Filesystem\Filesystem. Require the given file once.
  • public string sharedGet(string $path) - defined in Illuminate\Filesystem\Filesystem. Get contents of a file with shared access.
  • public int size(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the file size of a given file.
  • public string type(string $path) - defined in Illuminate\Filesystem\Filesystem. Get the file type of a given file.

Protected methods

protected void getRootSymlinks()

getRootSymlinks returns any unresolved symlinks in the public directory