October\Rain\Filesystem\Filesystem

Overview

Filesystem helper

Extends
  • Illuminate\Filesystem\Filesystem

Public Properties

public string $filePermissions

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

public string $folderPermissions

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

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

  • $macros - The registered string macros. (defined in Illuminate\Filesystem\Filesystem)

Public Methods

public anyname()

public anyname(string $path): string 

anyname extracts the path and filename without extension

public chmod()

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

chmod modifies file/folder permissions

public chmodRecursive()

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

chmodRecursive modifies file/folder permissions recursively

public copy()

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

copy a file to a new location.

public existsInsensitive()

public existsInsensitive(string $path): string|bool 

existsInsensitive determines if a file exists with case insensitivity supported for the file only. Returne either the sensitive path or false.

public fileNameMatch()

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

fileNameMatch matches filename against a pattern

public fromClass()

public fromClass(mixed $className): string 

fromClass finds the path to a class

public getFilePermissions()

public getFilePermissions(): string 

getFilePermissions returns the default file permission mask to use

public getFolderPermissions()

public getFolderPermissions(): string 

getFolderPermissions returns the default folder permission mask to use

public getSafe()

public getSafe($path, $limitKbs = 1.0): void

getSafe reads the first portion of file contents

public isDirectoryEmpty()

public isDirectoryEmpty(string $directory): bool 

isDirectoryEmpty determines if the given path contains no files

public isLocalPath()

public isLocalPath(string $path, bool $realpath = true): bool 

isLocalPath returns true if the specified path is within the path of the application. realpath resolves 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 isPathSymbol()

public isPathSymbol(string $path): bool|string 

isPathSymbol returns the symbol if the path uses a symbol, otherwise false

public lastModifiedRecursive()

public lastModifiedRecursive($path): void

lastModifiedRecursive checks an entire directory and returns the mtime of the freshest file.

public localToPublic()

public localToPublic(string $path): string 

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

public makeDirectory()

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

makeDirectory creates a directory

public nicePath()

public nicePath(string $path): string 

nicePath removes the base path from a local path and returns a relatively nice path that is suitable and safe for sharing.

public normalizePath()

public normalizePath(string $path): string 

normalizePath returns a normalized version of the supplied path for use in combined Windows and Unix systems.

public put()

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

put writes the contents of a file

public searchDirectory()

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

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

public sizeToString()

public sizeToString(int $bytes): string 

sizeToString converts a file size in bytes to human readable format

public symbolizePath()

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

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

Show inherited public methods

Inherited Public Methods

  • __call() - Dynamically handle calls to the class. (defined in Illuminate\Filesystem\Filesystem)
  • __callStatic() - Dynamically handle calls to the class. (defined in Illuminate\Filesystem\Filesystem)
  • allFiles() - Get all of the files from the given directory (recursive). (defined in Illuminate\Filesystem\Filesystem)
  • append() - Append to a file. (defined in Illuminate\Filesystem\Filesystem)
  • basename() - Extract the trailing name component from a file path. (defined in Illuminate\Filesystem\Filesystem)
  • cleanDirectory() - Empty the specified directory of all files and folders. (defined in Illuminate\Filesystem\Filesystem)
  • copyDirectory() - Copy a directory from one location to another. (defined in Illuminate\Filesystem\Filesystem)
  • delete() - Delete the file at a given path. (defined in Illuminate\Filesystem\Filesystem)
  • deleteDirectories() - Remove all of the directories within a given directory. (defined in Illuminate\Filesystem\Filesystem)
  • deleteDirectory() - Recursively delete a directory. (defined in Illuminate\Filesystem\Filesystem)
  • directories() - Get all of the directories within a given directory. (defined in Illuminate\Filesystem\Filesystem)
  • dirname() - Extract the parent directory from a file path. (defined in Illuminate\Filesystem\Filesystem)
  • ensureDirectoryExists() - Ensure a directory exists. (defined in Illuminate\Filesystem\Filesystem)
  • exists() - Determine if a file or directory exists. (defined in Illuminate\Filesystem\Filesystem)
  • extension() - Extract the file extension from a file path. (defined in Illuminate\Filesystem\Filesystem)
  • files() - Get an array of all files in a directory. (defined in Illuminate\Filesystem\Filesystem)
  • flushMacros() - Flush the existing macros. (defined in Illuminate\Filesystem\Filesystem)
  • get() - Get the contents of a file. (defined in Illuminate\Filesystem\Filesystem)
  • getRequire() - Get the returned value of a file. (defined in Illuminate\Filesystem\Filesystem)
  • glob() - Find path names matching a given pattern. (defined in Illuminate\Filesystem\Filesystem)
  • guessExtension() - Guess the file extension from the mime-type of a given file. (defined in Illuminate\Filesystem\Filesystem)
  • hasMacro() - Checks if macro is registered. (defined in Illuminate\Filesystem\Filesystem)
  • hasSameHash() - Determine if two files are the same by comparing their hashes. (defined in Illuminate\Filesystem\Filesystem)
  • hash() - Get the hash of the file at the given path. (defined in Illuminate\Filesystem\Filesystem)
  • isDirectory() - Determine if the given path is a directory. (defined in Illuminate\Filesystem\Filesystem)
  • isEmptyDirectory() - Determine if the given path is a directory that does not contain any other files or directories. (defined in Illuminate\Filesystem\Filesystem)
  • isFile() - Determine if the given path is a file. (defined in Illuminate\Filesystem\Filesystem)
  • isReadable() - Determine if the given path is readable. (defined in Illuminate\Filesystem\Filesystem)
  • isWritable() - Determine if the given path is writable. (defined in Illuminate\Filesystem\Filesystem)
  • lastModified() - Get the file's last modification time. (defined in Illuminate\Filesystem\Filesystem)
  • lines() - Get the contents of a file one line at a time. (defined in Illuminate\Filesystem\Filesystem)
  • link() - Create a symlink to the target file or directory. On Windows, a hard link is created if the target is a file. (defined in Illuminate\Filesystem\Filesystem)
  • macro() - Register a custom macro. (defined in Illuminate\Filesystem\Filesystem)
  • mimeType() - Get the mime-type of a given file. (defined in Illuminate\Filesystem\Filesystem)
  • missing() - Determine if a file or directory is missing. (defined in Illuminate\Filesystem\Filesystem)
  • mixin() - Mix another object into the class. (defined in Illuminate\Filesystem\Filesystem)
  • move() - Move a file to a new location. (defined in Illuminate\Filesystem\Filesystem)
  • moveDirectory() - Move a directory. (defined in Illuminate\Filesystem\Filesystem)
  • name() - Extract the file name from a file path. (defined in Illuminate\Filesystem\Filesystem)
  • prepend() - Prepend to a file. (defined in Illuminate\Filesystem\Filesystem)
  • relativeLink() - Create a relative symlink to the target file or directory. (defined in Illuminate\Filesystem\Filesystem)
  • replace() - Write the contents of a file, replacing it atomically if it already exists. (defined in Illuminate\Filesystem\Filesystem)
  • replaceInFile() - Replace a given string within a given file. (defined in Illuminate\Filesystem\Filesystem)
  • requireOnce() - Require the given file once. (defined in Illuminate\Filesystem\Filesystem)
  • sharedGet() - Get contents of a file with shared access. (defined in Illuminate\Filesystem\Filesystem)
  • size() - Get the file size of a given file. (defined in Illuminate\Filesystem\Filesystem)
  • type() - Get the file type of a given file. (defined in Illuminate\Filesystem\Filesystem)
  • unless() - Apply the callback if the given "value" is (or resolves to) falsy. (defined in Illuminate\Filesystem\Filesystem)
  • when() - Apply the callback if the given "value" is (or resolves to) truthy. (defined in Illuminate\Filesystem\Filesystem)

Protected Methods

protected getRootSymlinks()

protected getRootSymlinks(): array 

getRootSymlinks returns any unresolved symlinks in the public directory