Dir
Dir
- Full name:
\Hazaar\File\Dir
Properties
path
protected string $path
backend
protected \Hazaar\File\Backend\Interfaces\Backend $backend
manager
protected \Hazaar\File\Manager $manager
files
protected \Hazaar\File[] $files
allow_hidden
protected bool $allow_hidden
__media_uri
protected ?\Hazaar\HTTP\URL $__media_uri
relative_path
protected ?string $relative_path
Methods
__construct
public __construct(\Hazaar\File|string $path, ?\Hazaar\File\Manager $manager = null, ?string $relative_path = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$path | \Hazaar\File|string | |
$manager | ?\Hazaar\File\Manager | |
$relative_path | ?string |
__toString
public __toString(): string
backend
public backend(): string
getManager
public getManager(): \Hazaar\File\Manager
setMeta
public setMeta(array<string,int|string> $values): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$values | array<string,int|string> |
getMeta
public getMeta(?string $key = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$key | ?string |
toString
public toString(): string
path
public path(?string $suffix = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$suffix | ?string |
fullpath
public fullpath(?string $suffix = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$suffix | ?string |
relativepath
Get the relative path of the directory.
public relativepath(null|\Hazaar\File\Dir|\Hazaar\File|string $path = null): false|string
If the file was returned from a [[Hazaar\File\Dir]] object, then it will have a stored relative path. Otherwise any file/path can be provided in the form of another [[Hazaar\File\ object, [[Hazaar\File\Dir]] object, or string path, and the relative path to the file will be returned.
Parameters:
Parameter | Type | Description |
---|---|---|
$path | null|\Hazaar\File\Dir|\Hazaar\File|string |
setRelativePath
public setRelativePath(string $path): void
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
realpath
public realpath(): string
dirname
public dirname(): string
name
public name(): string
extension
public extension(): string
basename
public basename(): string
size
public size(): int
type
public type(): string
exists
public exists(?string $filename = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$filename | ?string |
isReadable
public isReadable(): bool
isWritable
public isWritable(): bool
isFile
public isFile(): bool
isDir
public isDir(): bool
isLink
public isLink(): bool
parent
public parent(): \Hazaar\File\Dir
ctime
public ctime(): false|int
mtime
public mtime(): false|int
touch
public touch(): bool
atime
public atime(): false|int
allowHidden
public allowHidden(bool $toggle = true): void
Parameters:
Parameter | Type | Description |
---|---|---|
$toggle | bool |
create
public create(bool $recursive = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$recursive | bool |
rename
public rename(string $newname): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$newname | string |
delete
Delete the directory, optionally removing all it's contents.
public delete(bool $recursive = false): bool
Executing this method will simply delete or "unlink" the directory. Normally it must be empty to succeed. However specifying the $recursive parameter as TRUE will delete everything inside the directory, recursively (obviously).
Parameters:
Parameter | Type | Description |
---|---|---|
$recursive | bool |
unlink
File::unlink() compatible delete that removes dir and all contents (ie: recursive).
public unlink(): bool
isEmpty
public isEmpty(): bool
empty
Empty a directory of all it's contents.
public empty(mixed $include_hidden = false): bool
This is the same as calling delete(true) except that the directory itself is not deleted.
By default hidden files are not deleted. This is for protection. You can choose to delete them as well by setting $include_hidden to true.
Parameters:
Parameter | Type | Description |
---|---|---|
$include_hidden | mixed | also delete hidden files |
close
public close(): void
read
public read(?string $regex_filter = null): false|\Hazaar\File
Parameters:
Parameter | Type | Description |
---|---|---|
$regex_filter | ?string |
rewind
public rewind(): void
find
Find files in the current path optionally recursing into sub directories.
public find(string $pattern, bool $show_hidden = false, bool $case_sensitive = true, int $depth = null): \Hazaar\File[]
Parameters:
Parameter | Type | Description |
---|---|---|
$pattern | string | The pattern to match against. This can be either a wildcard string, such as "*.txt" or a regex pattern. Regex is detected if the string is longer than a single character and first character is the same as the last. |
$show_hidden | bool | |
$case_sensitive | bool | if TRUE character case will be honoured |
$depth | int | Recursion depth. NULL will always recurse. 0 will prevent recursion. |
Return Value:
returns an array of matches files
copyTo
public copyTo(string $target, bool $recursive = false, null|callable|\Closure $transport_callback = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$target | string | |
$recursive | bool | |
$transport_callback | null|callable|\Closure |
get
public get(string $child, bool $force_dir = false): \Hazaar\File\Dir|\Hazaar\File
Parameters:
Parameter | Type | Description |
---|---|---|
$child | string | |
$force_dir | bool |
getDir
public getDir(string $path): \Hazaar\File\Dir
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
mimeContentType
public mimeContentType(): string
dir
public dir(?string $child = null): \Hazaar\File\Dir
Parameters:
Parameter | Type | Description |
---|---|---|
$child | ?string |
toArray
public toArray(): string[]
put
Copy a file object into the current directory.
public put(\Hazaar\File $file, bool $overwrite = false): \Hazaar\File
Parameters:
Parameter | Type | Description |
---|---|---|
$file | \Hazaar\File | The file to put in this directory |
$overwrite | bool |
download
Download a file from a URL directly to the directory and return a new File object.
public download(mixed $source_url, mixed $timeout = 60): \Hazaar\File
This is useful for download large files as this method will write the file directly to storage. Currently, only local storage is supported as this uses OS file access.
Parameters:
Parameter | Type | Description |
---|---|---|
$source_url | mixed | The source URL of the file to download |
$timeout | mixed | The download timeout after which an exception will be thrown |
Return Value:
A file object for accessing the newly created file
Throws:
mediaURL
public mediaURL(null|string|\Hazaar\HTTP\URL $set_path = null): ?\Hazaar\HTTP\URL
Parameters:
Parameter | Type | Description |
---|---|---|
$set_path | null|string|\Hazaar\HTTP\URL |
sync
public sync(\Hazaar\File\Dir $source, bool $recursive = false, null|callable|\Closure $progress_callback = null, int $max_retries = 3): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$source | \Hazaar\File\Dir | |
$recursive | bool | |
$progress_callback | null|callable|\Closure | |
$max_retries | int |
write
public write(string $file, string $bytes, ?string $content_type = null): ?int
Parameters:
Parameter | Type | Description |
---|---|---|
$file | string | |
$bytes | string | |
$content_type | ?string |
callSyncCallback
private callSyncCallback(): bool
Automatically generated on 2024-11-14