DirectoryIterator
class DirectoryIterator extends SplFileInfo implements SeekableIterator (View source)
The DirectoryIterator class provides a simple interface for viewing the contents of filesystem directories.
Methods
Constructs a new directory iterator from a path
Gets an SplFileInfo object for the path
Gets an SplFileObject object for the file
Sets the class name used with SplFileInfo::openFile
Sets the class used with getFileInfo and getPathInfo
Determine if current DirectoryIterator item is '.' or '..'
Rewind the DirectoryIterator back to the start
Check whether current DirectoryIterator position is a valid file
Return the key for the current DirectoryIterator item
Return the current DirectoryIterator item.
Move forward to next DirectoryIterator item
Seek to a DirectoryIterator item
Details
__construct(string $directory)
Constructs a new directory iterator from a path
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
SplFileInfo
getFileInfo(T> $class = null)
Gets an SplFileInfo object for the file
SplFileInfo|null
getPathInfo(T> $class = null)
Gets an SplFileInfo object for the path
SplFileObject
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
final void
_bad_state_ex()
No description
__wakeup()
No description
array
__debugInfo()
No description
bool
isDot()
Determine if current DirectoryIterator item is '.' or '..'
void
rewind()
Rewind the DirectoryIterator back to the start
bool
valid()
Check whether current DirectoryIterator position is a valid file
mixed
key()
Return the key for the current DirectoryIterator item
mixed
current()
Return the current DirectoryIterator item.
void
next()
Move forward to next DirectoryIterator item
void
seek(int $offset)
Seek to a DirectoryIterator item