Filesystem
File helper
class Winter\Storm\Filesystem\Filesystem
extends Illuminate\Filesystem\Filesystem
Extends
Class | Description |
---|---|
Illuminate\Filesystem\Filesystem
|
Properties
public
$filePermissions
:
string
|
null
= null
Default file permission mask as a string ("777").
public
$folderPermissions
:
string
|
null
= null
Default folder permission mask as a string ("777").
public
$pathSymbols
:
array
= []
Known path symbols and their prefixes.
protected
$symlinks
:
array
|
null
= null
Symlinks within base folder
Methods
public
chmod (string $path, int | float | null $mask = null
)
: bool
Modify file/folder permissions.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$mask | int | float | null |
int | float | null
|
public
chmodRecursive (string $path, $fileMask = null
, $directoryMask = null
)
: void
Modify file/folder permissions recursively in a given path.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$fileMask | mixed |
mixed
|
$directoryMask | mixed |
mixed
|
public copy (string $path, string $target) : bool
Copy a file to a new location.
This method will also set the permissions based on the given chmod() mask in use.
Returns true
if successful, or false
on failure.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$target | string |
string
|
public existsInsensitive (string $path) : string | false
Determines if a file exists (ignoring the case for the filename only).
Property | Type | Description |
---|---|---|
$path | string |
string
|
public fileNameMatch (string $fileName, string $pattern) : bool
Match filename against a pattern.
Property | Type | Description |
---|---|---|
$fileName | string |
string
|
$pattern | string |
string
|
public fromClass (string | object $className) : string | false
Finds the path of a given class.
Returns false
if the path cannot be determined.
Property | Type | Description |
---|---|---|
$className | string | object |
string | object
Class name or object |
public getFilePermissions () : integer | float | null
Returns the default file permission mask to use.
public getFolderPermissions () : integer | float | null
Returns the default folder permission mask to use.
public isAbsolutePath (string $file) : bool
Returns whether the file path is an absolute path.
Property | Type | Description |
---|---|---|
$file | string |
string
|
public isDirectoryEmpty (string $directory) : bool | null
Determine if the given path contains no files.
Returns a boolean regarding if the directory is empty or not. If the directory does not exist or is not
readable, this method will return null
.
Property | Type | Description |
---|---|---|
$directory | string |
string
|
public isLocalDisk (Illuminate\Filesystem\FilesystemAdapter $disk) : bool
Determines if the given disk is using the "local" driver.
Property | Type | Description |
---|---|---|
$disk | Illuminate\Filesystem\FilesystemAdapter |
Illuminate\Filesystem\FilesystemAdapter
|
public
isLocalPath (string $path, boolean $realpath = true
)
: bool
Determines if the given path is a local path.
Returns true
if the path is local, false
otherwise.
Property | Type | Description |
---|---|---|
$path | string |
string
The path to check |
$realpath | boolean |
boolean
If |
public isPathSymbol (string $path) : bool
Determines if the given path is using a path symbol.
Property | Type | Description |
---|---|---|
$path | string |
string
|
public localToPublic (string $path) : string | null
Returns a public file path from an absolute path.
Eg: /home/mysite/public_html/welcome
-> /welcome
Returns null
if the path cannot be converted.
Property | Type | Description |
---|---|---|
$path | string |
string
|
public
makeDirectory (string $path, integer $mode = 511
, boolean $recursive = false
, boolean $force = false
)
: bool
Create a directory.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$mode | integer |
integer
|
$recursive | boolean |
boolean
|
$force | boolean |
boolean
|
public normalizePath (string $path) : string
Normalizes the directory separator, often used by Windows systems.
Property | Type | Description |
---|---|---|
$path | string |
string
|
public
put (string $path, string $contents, boolean $lock = false
)
: int | false
Write the contents of a file.
This method will also set the permissions based on the given chmod() mask in use.
Returns the number of bytes written to the file, or false
on failure.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$contents | string |
string
|
$lock | boolean |
boolean
|
public sizeToString (integer $bytes) : string
Converts a file size in bytes to a human readable format.
Property | Type | Description |
---|---|---|
$bytes | integer |
integer
|
public
symbolizePath (string $path, $default = null
)
: string
Converts a path using path symbol.
Returns the original path if no symbol is used, and no default is specified.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$default | mixed |
mixed
|
protected findSymlinks () : void
Finds symlinks within the base path and populates the local symlinks property with an array of source => target symlinks.