Dir
Dir
Represent dir.
class DirProperties
path
Store the path.
protected string $pathType: string
backend
Store the backend.
protected Backend $backendType: Hazaar\File\Interface\Backend
manager
Store the manager.
protected Manager $managerType: Hazaar\File\Manager
files
public array $filesType: array
allowHidden
Store the allow hidden.
protected bool $allowHiddenType: bool
__media_uri
public URL $__media_uriType: Hazaar\HTTP\URL
relativePath
public string $relativePathType: string
Methods
__construct
Create a new instance.
public __construct(File|string $path, ?Manager $manager, ?string $relativePath): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | Hazaar\File | string |
$manager | Hazaar\File\Manager | |
$relativePath | string |
__toString
Convert the instance to a string representation.
public __toString(): stringReturns: string
backend
Execute the backend operation for this file component.
public backend(): stringReturns: string
getManager
Get the manager.
public getManager(): ManagerReturns: Hazaar\File\Manager
setMeta
public setMeta(array $values): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$values | array |
getMeta
Get the meta.
public getMeta(?string $key): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
toString
To string.
public toString(): stringReturns: string
path
Execute the path operation for this file component.
public path(?string $suffix): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$suffix | string |
fullpath
Execute the fullpath operation for this file component.
public fullpath(?string $suffix): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$suffix | string |
relativepath
Get the relative path of the directory.
public relativepath(Dir|File|string|null $path): false|stringReturns: 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 | Hazaar\File\Dir | Hazaar\File |
setRelativePath
Set the relative path.
public setRelativePath(string $path): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
realpath
Resolve a logical backend path to its canonical remote representation.
public realpath(): stringReturns: string
dirname
Execute the dirname operation for this file component.
public dirname(): stringReturns: string
name
Execute the name operation for this file component.
public name(): stringReturns: string
extension
Execute the extension operation for this file component.
public extension(): stringReturns: string
basename
Execute the basename operation for this file component.
public basename(): stringReturns: string
size
Execute the size operation for this file component.
public size(): intReturns: int
type
Execute the type operation for this file component.
public type(): stringReturns: string
exists
Determine whether a path exists in backend storage.
public exists(?string $filename): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$filename | string |
isReadable
Check whether the instance readable.
public isReadable(): boolReturns: bool
isWritable
Check whether the instance writable.
public isWritable(): boolReturns: bool
isFile
Check whether the instance file.
public isFile(): boolReturns: bool
isDir
Check whether the instance dir.
public isDir(): boolReturns: bool
isLink
Check whether the instance link.
public isLink(): boolReturns: bool
parent
Execute the parent operation for this file component.
public parent(): DirReturns: Hazaar\File\Dir
ctime
Execute the ctime operation for this file component.
public ctime(): false|intReturns: false|int
mtime
Execute the mtime operation for this file component.
public mtime(): false|intReturns: false|int
touch
Create a file or update modification time for a backend path.
public touch(): boolReturns: bool
atime
Execute the atime operation for this file component.
public atime(): false|intReturns: false|int
allowHidden
Allow hidden.
public allowHidden(bool $toggle = true): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$toggle | bool |
create
Execute the create operation for this file component.
public create(bool $recursive): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$recursive | bool |
rename
Execute the rename operation for this file component.
public rename(string $newname): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$newname | string |
delete
Delete the directory, optionally removing all it's contents.
public delete(bool $recursive): boolReturns: 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(): boolReturns: bool
isEmpty
Check whether the instance empty.
public isEmpty(): boolReturns: bool
Empty a directory of all it's contents.
public (bool $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 | bool | also delete hidden files |
close
Execute the close operation for this file component.
public close(): voidReturns: void
read
Read and return file contents from backend storage.
public read(?string $regexFilter): false|FileReturns: false|Hazaar\File
Parameters
| Parameter | Type | Description |
|---|---|---|
$regexFilter | string |
rewind
Execute the rewind operation for this file component.
public rewind(): voidReturns: void
find
Find files in the current path optionally recursing into sub directories.
public find(string $pattern, bool $showHidden, bool $caseSensitive = true, ?int $depth): ?arrayReturns: array
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. |
$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, callable|\Closure|null $transportCallback): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$target | string | |
$recursive | bool | |
$transportCallback | callable | Closure |
get
Return the requested value from the current file abstraction.
public get(string $child, bool $forceDir): Dir|FileReturns: Hazaar\File\Dir|Hazaar\File
Parameters
| Parameter | Type | Description |
|---|---|---|
$child | string | |
$forceDir | bool |
getDir
Get the dir.
public getDir(string $path): DirReturns: Hazaar\File\Dir
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
mimeContentType
Mime content type.
public mimeContentType(): stringReturns: string
dir
Execute the dir operation for this file component.
public dir(?string $child): DirReturns: Hazaar\File\Dir
Parameters
| Parameter | Type | Description |
|---|---|---|
$child | string |
toArray
public toArray(): arrayReturns: array
put
Copy a file object into the current directory.
public put(File $file, bool $overwrite): FileReturns: 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 $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(string|URL|null $setPath): ?URLReturns: Hazaar\HTTP\URL
Parameters
| Parameter | Type | Description |
|---|---|---|
$setPath | string | Hazaar\HTTP\URL |
sync
Execute the sync operation for this file component.
public sync(Dir $source, bool $recursive, callable|\Closure|null $progressCallback, int $maxRetries = 3): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$source | Hazaar\File\Dir | |
$recursive | bool | |
$progressCallback | callable | Closure |
$maxRetries | int |
write
Write content to a backend path and return bytes written.
public write(string $file, string $bytes, ?string $contentType): ?intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$file | string | |
$bytes | string | |
$contentType | string |
callSyncCallback
Call sync callback.
private callSyncCallback(): boolReturns: bool
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000