Documentation

Dir
in package
implements ArrayAccess, Countable, IteratorAggregate

Directory class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

Table of Contents

Interfaces

ArrayAccess
Countable
IteratorAggregate

Properties

$absolute  : bool
Flag to store the absolute path.
$files  : array<string|int, mixed>
The files within the directory
$filesOnly  : bool
Flag to include only files and no directories
$path  : string|null
The directory path
$recursive  : bool
Flag to dig recursively.
$relative  : bool
Flag to store the relative path.
$tree  : array<string|int, mixed>
The nested tree map of the directory and its files

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Get a file
__isset()  : bool
Does file exist
__set()  : void
Set method
__unset()  : void
Unset method
copyTo()  : void
Copy an entire directory recursively to another destination directory
count()  : int
Method to get the count of files in the directory
deleteFile()  : void
Delete a file
emptyDir()  : void
Empty an entire directory
fileExists()  : bool
File exists
getFiles()  : array<string|int, mixed>
Get the files
getIterator()  : ArrayIterator
Method to iterate over the files
getPath()  : string|null
Get the path
getTree()  : array<string|int, mixed>
Get the tree
isAbsolute()  : bool
Is absolute
isFilesOnly()  : bool
Is files only
isRecursive()  : bool
Is recursive
isRelative()  : bool
Is relative
offsetExists()  : bool
ArrayAccess offsetExists
offsetGet()  : mixed
ArrayAccess offsetGet
offsetSet()  : void
ArrayAccess offsetSet
offsetUnset()  : void
ArrayAccess offsetUnset
setAbsolute()  : Dir
Set absolute
setFilesOnly()  : Dir
Set files only
setRecursive()  : Dir
Set recursive
setRelative()  : Dir
Set relative
buildTree()  : array<string|int, mixed>
Build the directory tree
traverse()  : void
Traverse the directory
traverseRecursively()  : void
Traverse the directory recursively

Properties

$absolute

Flag to store the absolute path.

protected bool $absolute = false

$files

The files within the directory

protected array<string|int, mixed> $files = []

$filesOnly

Flag to include only files and no directories

protected bool $filesOnly = false

$path

The directory path

protected string|null $path = null

$recursive

Flag to dig recursively.

protected bool $recursive = false

$relative

Flag to store the relative path.

protected bool $relative = false

$tree

The nested tree map of the directory and its files

protected array<string|int, mixed> $tree = []

Methods

__construct()

Constructor

public __construct(string $dir[, array<string|int, mixed> $options = [] ]) : mixed

Instantiate a directory object

Parameters
$dir : string
$options : array<string|int, mixed> = []
Tags
throws
Exception

__get()

Get a file

public __get(string $name) : mixed
Parameters
$name : string

__isset()

Does file exist

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

Set method

public __set(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Tags
throws
Exception

__unset()

Unset method

public __unset(string $name) : void
Parameters
$name : string
Tags
throws
Exception

copyTo()

Copy an entire directory recursively to another destination directory

public copyTo(string $destination[, bool $full = true ]) : void
Parameters
$destination : string
$full : bool = true

count()

Method to get the count of files in the directory

public count() : int
Return values
int

deleteFile()

Delete a file

public deleteFile(string $file) : void
Parameters
$file : string
Tags
throws
Exception

emptyDir()

Empty an entire directory

public emptyDir([bool $remove = false ][, string|null $path = null ]) : void
Parameters
$remove : bool = false
$path : string|null = null
Tags
throws
Exception

fileExists()

File exists

public fileExists(string $file) : bool
Parameters
$file : string
Return values
bool

getFiles()

Get the files

public getFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

getIterator()

Method to iterate over the files

public getIterator() : ArrayIterator
Return values
ArrayIterator

getPath()

Get the path

public getPath() : string|null
Return values
string|null

getTree()

Get the tree

public getTree() : array<string|int, mixed>
Return values
array<string|int, mixed>

isAbsolute()

Is absolute

public isAbsolute() : bool
Return values
bool

isFilesOnly()

Is files only

public isFilesOnly() : bool
Return values
bool

isRecursive()

Is recursive

public isRecursive() : bool
Return values
bool

isRelative()

Is relative

public isRelative() : bool
Return values
bool

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

ArrayAccess offsetGet

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

ArrayAccess offsetSet

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Tags
throws
Exception

offsetUnset()

ArrayAccess offsetUnset

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Tags
throws
Exception

setAbsolute()

Set absolute

public setAbsolute(bool $absolute) : Dir
Parameters
$absolute : bool
Return values
Dir

setFilesOnly()

Set files only

public setFilesOnly(bool $filesOnly) : Dir
Parameters
$filesOnly : bool
Return values
Dir

setRecursive()

Set recursive

public setRecursive(bool $recursive) : Dir
Parameters
$recursive : bool
Return values
Dir

setRelative()

Set relative

public setRelative(bool $relative) : Dir
Parameters
$relative : bool
Return values
Dir

buildTree()

Build the directory tree

protected buildTree(DirectoryIterator $it) : array<string|int, mixed>
Parameters
$it : DirectoryIterator
Return values
array<string|int, mixed>

traverse()

Traverse the directory

protected traverse() : void

traverseRecursively()

Traverse the directory recursively

protected traverseRecursively() : void

        
On this page

Search results