class GlobIterator extends FilesystemIterator implements Countable (View source)

Iterates through a file system in a similar fashion to glob.

Constants

CURRENT_MODE_MASK

CURRENT_AS_PATHNAME

CURRENT_AS_FILEINFO

CURRENT_AS_SELF

KEY_MODE_MASK

KEY_AS_PATHNAME

FOLLOW_SYMLINKS

KEY_AS_FILENAME

NEW_CURRENT_AND_KEY

SKIP_DOTS

UNIX_PATHS

OTHER_MODE_MASK

Methods

__construct($pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO)

Construct a directory using glob

string
getPath()

Gets the path without filename

string
getFilename()

Gets the filename

string
getExtension()

Gets the file extension

string
getBasename(string $suffix = '')

Gets the base name of the file

string
getPathname()

Gets the path to the file

int|false
getPerms()

Gets file permissions

int|false
getInode()

Gets the inode for the file

int|false
getSize()

Gets file size

int|false
getOwner()

Gets the owner of the file

int|false
getGroup()

Gets the file group

int|false
getATime()

Gets last access time of the file

int|false
getMTime()

Gets the last modified time

int|false
getCTime()

Gets the inode change time

string|false
getType()

Gets file type

bool
isWritable()

Tells if the entry is writable

bool
isReadable()

Tells if file is readable

bool
isExecutable()

Tells if the file is executable

bool
isFile()

Tells if the object references a regular file

bool
isDir()

Tells if the file is a directory

bool
isLink()

Tells if the file is a link

string|false
getLinkTarget()

Gets the target of a link

string|false
getRealPath()

Gets absolute path to file

getFileInfo(T> $class = null)

Gets an SplFileInfo object for the file

getPathInfo(T> $class = null)

Gets an SplFileInfo object for the path

openFile(string $mode = 'r', bool $useIncludePath = false, resource $context = null)

Gets an SplFileObject object for the file

void
setFileClass(T> $class = SplFileObject::class)

Sets the class name used with SplFileInfo::openFile

void
setInfoClass(T> $class = SplFileInfo::class)

Sets the class used with getFileInfo and getPathInfo

string
__toString()

Returns the path to the file as a string

void
_bad_state_ex()

No description

__wakeup()

No description

array
__debugInfo()

No description

bool
isDot()

Determine if current DirectoryIterator item is '.' or '..'

void
rewind()

Rewinds back to the beginning

bool
valid()

Check whether current DirectoryIterator position is a valid file

mixed
key()

Retrieve the key for the current file

mixed
current()

The current file

void
next()

Move to the next file

void
seek(int $offset)

Seek to a DirectoryIterator item

int
getFlags()

Get the handling flags

void
setFlags(int $flags)

Sets handling flags

int
count()

Get the number of directories and files

Details

__construct($pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO)

Construct a directory using glob

Parameters

$pattern
int $flags [optional]

string getPath()

Since: 5.1.2

Gets the path without filename

Return Value

string

the path to the file.

string getFilename()

Since: 5.1.2

Gets the filename

Return Value

string

The filename.

string getExtension()

Since: 5.3.6

Gets the file extension

Return Value

string

a string containing the file extension, or an empty string if the file has no extension.

string getBasename(string $suffix = '')

Since: 5.2.2

Gets the base name of the file

Parameters

string $suffix

[optional]

Optional suffix to omit from the base name returned.

Return Value

string

the base name without path information.

string getPathname()

Since: 5.1.2

Gets the path to the file

Return Value

string

The path to the file.

int|false getPerms()

Since: 5.1.2

Gets file permissions

Return Value

int|false

The file permissions on success, or FALSE on failure.

int|false getInode()

Since: 5.1.2

Gets the inode for the file

Return Value

int|false

The inode number for the filesystem object on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getSize()

Since: 5.1.2

Gets file size

Return Value

int|false

The filesize in bytes on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getOwner()

Since: 5.1.2

Gets the owner of the file

Return Value

int|false

The owner id in numerical format on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getGroup()

Since: 5.1.2

Gets the file group

Return Value

int|false

The group id in numerical format on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getATime()

Since: 5.1.2

Gets last access time of the file

Return Value

int|false

The time the file was last accessed on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getMTime()

Since: 5.1.2

Gets the last modified time

Return Value

int|false

The last modified time for the file, in a Unix timestamp on success, or FALSE on failure.

int|false getCTime()

Since: 5.1.2

Gets the inode change time

Return Value

int|false

The last change time, in a Unix timestamp on success, or FALSE on failure.

Exceptions

RuntimeException

string|false getType()

Since: 5.1.2

Gets file type

Return Value

string|false

A string representing the type of the entry. May be one of file, link, dir, block, fifo, char, socket, or unknown, or FALSE on failure. May be one of file, link, or dir

Exceptions

RuntimeException

bool isWritable()

Since: 5.1.2

Tells if the entry is writable

Return Value

bool

true if writable, false otherwise;

bool isReadable()

Since: 5.1.2

Tells if file is readable

Return Value

bool

true if readable, false otherwise.

bool isExecutable()

Since: 5.1.2

Tells if the file is executable

Return Value

bool

true if executable, false otherwise.

bool isFile()

Since: 5.1.2

Tells if the object references a regular file

Return Value

bool

true if the file exists and is a regular file (not a link), false otherwise.

bool isDir()

Since: 5.1.2

Tells if the file is a directory

Return Value

bool

true if a directory, false otherwise.

Since: 5.1.2

Tells if the file is a link

Return Value

bool

true if the file is a link, false otherwise.

string|false getLinkTarget()

Since: 5.2.2

Gets the target of a link

Return Value

string|false

The target of the filesystem link on success, or FALSE on failure.

Exceptions

RuntimeException

string|false getRealPath()

Since: 5.2.2

Gets absolute path to file

Return Value

string|false

the path to the file, or FALSE if the file does not exist.

SplFileInfo getFileInfo(T> $class = null)

Since: 5.1.2

Gets an SplFileInfo object for the file

Parameters

T> $class

[optional]

Name of an SplFileInfo derived class to use.

Return Value

SplFileInfo

An SplFileInfo object created for the file.

SplFileInfo|null getPathInfo(T> $class = null)

Since: 5.1.2

Gets an SplFileInfo object for the path

Parameters

T> $class

[optional]

Name of an SplFileInfo derived class to use.

Return Value

SplFileInfo|null

A SplFileInfo object for the parent path of the file on success, or NULL on failure.

SplFileObject openFile(string $mode = 'r', bool $useIncludePath = false, resource $context = null)

Since: 5.1.2

Gets an SplFileObject object for the file

Parameters

string $mode

[optional]

The mode for opening the file. See the fopen documentation for descriptions of possible modes. The default is read only.

bool $useIncludePath

[optional]

resource $context

[optional]

Return Value

SplFileObject

The opened file as an SplFileObject object.

Exceptions

RuntimeException

void setFileClass(T> $class = SplFileObject::class)

Since: 5.1.2

Sets the class name used with SplFileInfo::openFile

Parameters

T> $class

[optional]

The class name to use when openFile() is called.

Return Value

void

void setInfoClass(T> $class = SplFileInfo::class)

Since: 5.1.2

Sets the class used with getFileInfo and getPathInfo

Parameters

T> $class

[optional]

The class name to use.

Return Value

void

string __toString()

Since: 5.1.2

Returns the path to the file as a string

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

final void _bad_state_ex()

No description

Return Value

void

__wakeup()

No description

array __debugInfo()

Since: 7.4

No description

Return Value

array

bool isDot()

Determine if current DirectoryIterator item is '.' or '..'

Return Value

bool

true if the entry is . or .., otherwise false

void rewind()

Rewinds back to the beginning

Return Value

void

Any returned value is ignored.

bool valid()

Check whether current DirectoryIterator position is a valid file

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed key()

Retrieve the key for the current file

Return Value

mixed

TKey on success, or null on failure.

mixed current()

The current file

Return Value

mixed

Can return any type.

void next()

Move to the next file

Return Value

void

Any returned value is ignored.

void seek(int $offset)

Seek to a DirectoryIterator item

Parameters

int $offset

The position to seek to.

Return Value

void

int getFlags()

Get the handling flags

Return Value

int

The integer value of the set flags.

void setFlags(int $flags)

Sets handling flags

Parameters

int $flags

The handling flags to set. See the FilesystemIterator constants.

Return Value

void

int count()

Get the number of directories and files

Return Value

int

The custom count as an integer.

The return value is cast to an integer.