Documentation

Dir
in package
implements ArrayAccess, Countable, IteratorAggregate

Directory class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

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

license

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

version
3.2.0

Interfaces, Classes and Traits

ArrayAccess
Countable
IteratorAggregate

Table of Contents

$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
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
__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
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 $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
Return values
mixed

__get()

Get a file

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

__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
Return values
void

__unset()

Unset method

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

copyTo()

Copy an entire directory recursively to another destination directory

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

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
Return values
void

emptyDir()

Empty an entire directory

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

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
Return values
string

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
Return values
mixed

offsetSet()

ArrayAccess offsetSet

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

offsetUnset()

ArrayAccess offsetUnset

public offsetUnset(string $offset) : void
Parameters
$offset : string
Tags
throws
Exception
Return values
void

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
Return values
void

traverseRecursively()

Traverse the directory recursively

protected traverseRecursively() : void
Return values
void

Search results