Dir
Dir
Represent dir.
class DirProperties
path
Store the path.
protected string $pathbackend
Store the backend.
protected Backend $backendmanager
Store the manager.
protected Manager $managerfiles
public array $filesallowHidden
Store the allow hidden.
protected bool $allowHidden__media_uri
public URL $__media_urirelativePath
public string $relativePathMethods
__construct
Create a new instance.
public __construct(string $path, ?Manager $manager, ?string $relativePath): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$manager | Manager | |
$relativePath | string |
__toString
Convert the instance to a string representation.
public __toString(): stringbackend
Execute the backend operation for this file component.
public backend(): stringgetManager
Get the manager.
public getManager(): ManagersetMeta
public setMeta(array $values): boolParameters
| Parameter | Type | Description |
|---|---|---|
$values | array |
getMeta
Get the meta.
public getMeta(?string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
toString
To string.
public toString(): stringpath
Execute the path operation for this file component.
public path(?string $suffix): stringParameters
| Parameter | Type | Description |
|---|---|---|
$suffix | string |
fullpath
Execute the fullpath operation for this file component.
public fullpath(?string $suffix): stringParameters
| Parameter | Type | Description |
|---|---|---|
$suffix | string |
relativepath
Get the relative path of the directory.
public relativepath(null $path): stringIf 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 |
setRelativePath
Set the relative path.
public setRelativePath(string $path): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
realpath
Resolve a logical backend path to its canonical remote representation.
public realpath(): stringdirname
Execute the dirname operation for this file component.
public dirname(): stringname
Execute the name operation for this file component.
public name(): stringextension
Execute the extension operation for this file component.
public extension(): stringbasename
Execute the basename operation for this file component.
public basename(): stringsize
Execute the size operation for this file component.
public size(): inttype
Execute the type operation for this file component.
public type(): stringexists
Determine whether a path exists in backend storage.
public exists(?string $filename): boolParameters
| Parameter | Type | Description |
|---|---|---|
$filename | string |
isReadable
Check whether the instance readable.
public isReadable(): boolisWritable
Check whether the instance writable.
public isWritable(): boolisFile
Check whether the instance file.
public isFile(): boolisDir
Check whether the instance dir.
public isDir(): boolisLink
Check whether the instance link.
public isLink(): boolparent
Execute the parent operation for this file component.
public parent(): Dirctime
Execute the ctime operation for this file component.
public ctime(): intmtime
Execute the mtime operation for this file component.
public mtime(): inttouch
Create a file or update modification time for a backend path.
public touch(): boolatime
Execute the atime operation for this file component.
public atime(): intallowHidden
Allow hidden.
public allowHidden(bool $toggle = true): voidParameters
| Parameter | Type | Description |
|---|---|---|
$toggle | bool |
create
Execute the create operation for this file component.
public create(bool $recursive): boolParameters
| Parameter | Type | Description |
|---|---|---|
$recursive | bool |
rename
Execute the rename operation for this file component.
public rename(string $newname): boolParameters
| Parameter | Type | Description |
|---|---|---|
$newname | string |
delete
Delete the directory, optionally removing all it's contents.
public delete(bool $recursive): boolExecuting 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(): boolisEmpty
Check whether the instance empty.
public isEmpty(): boolEmpty a directory of all it's contents.
public (boolean $includeHidden): voidThis 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 $includeHidden to true.
Parameters
| Parameter | Type | Description |
|---|---|---|
$includeHidden | boolean | also delete hidden files |
close
Execute the close operation for this file component.
public close(): voidread
Read and return file contents from backend storage.
public read(?string $regexFilter): FileParameters
| Parameter | Type | Description |
|---|---|---|
$regexFilter | string |
rewind
Execute the rewind operation for this file component.
public rewind(): voidfind
Find files in the current path optionally recursing into sub directories.
public find(string $pattern, bool $showHidden, bool $caseSensitive = true, ?int $depth): voidParameters
| 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. |
$showHidden | bool | |
$caseSensitive | bool | if TRUE character case will be honoured |
$depth | int | Recursion depth. NULL will always recurse. 0 will prevent recursion. |
copyTo
Copy to.
public copyTo(string $target, bool $recursive, null $transportCallback): boolParameters
| Parameter | Type | Description |
|---|---|---|
$target | string | |
$recursive | bool | |
$transportCallback | null |
get
Return the requested value from the current file abstraction.
public get(string $child, bool $forceDir): FileParameters
| Parameter | Type | Description |
|---|---|---|
$child | string | |
$forceDir | bool |
getDir
Get the dir.
public getDir(string $path): DirParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
mimeContentType
Mime content type.
public mimeContentType(): stringdir
Execute the dir operation for this file component.
public dir(?string $child): DirParameters
| Parameter | Type | Description |
|---|---|---|
$child | string |
toArray
public toArray(): voidput
Copy a file object into the current directory.
public put(File $file, bool $overwrite): FileParameters
| Parameter | Type | Description |
|---|---|---|
$file | 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 $sourceUrl, int $timeout = 60): voidThis 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 |
|---|---|---|
$sourceUrl | mixed | The source URL of the file to download |
$timeout | int | The download timeout after which an exception will be thrown |
mediaURL
Media u r l.
public mediaURL(null $setPath): ?URLParameters
| Parameter | Type | Description |
|---|---|---|
$setPath | null |
sync
Execute the sync operation for this file component.
public sync(Dir $source, bool $recursive, null $progressCallback, int $maxRetries = 3): boolParameters
| Parameter | Type | Description |
|---|---|---|
$source | Dir | |
$recursive | bool | |
$progressCallback | null | |
$maxRetries | int |
write
Write content to a backend path and return bytes written.
public write(string $file, string $bytes, ?string $contentType): ?intParameters
| Parameter | Type | Description |
|---|---|---|
$file | string | |
$bytes | string | |
$contentType | string |
callSyncCallback
Call sync callback.
private callSyncCallback(): boolGenerated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000