
Public Member Functions | |
| getParent () | |
| Alias for getContainingFolder(). | |
| getFilesRecursive (array $suffixes, &$newest) | |
| Gets all files with any of the given suffixes in the folder recursively. | |
| getFilesWithAliasRecursive (array $suffixes, &$newest, $alias) | |
| Almost the same as getFilesRecursive(), but generates aliases as well. | |
| getFilesByRegex ($regex, $includeHidden=true) | |
| getFilesBySuffix ($suffix, $includeHidden=true) | |
| Get all files in this folder with given suffix. | |
| getFiles ($includeHidden=true) | |
| Fetches all files in this folder. | |
| getFolders ($includeHidden=true) | |
| Fetches all sub-folders in this folder. | |
| getFile ($name) | |
| Gets a file in - or relative to - this folder. | |
| getFolder ($name) | |
| Gets a folder in - or relative to - this folder. | |
| getPathTo (spunQ_IFileNode $node) | |
| Will give the path from this folder to another file node. | |
| getBreadcrumbsTo (spunQ_IFileNode $node) | |
| Does the same as getPathTo(), merely the result has a different format. | |
| create () | |
| Makes sure this folder exists - creating parent folders if necessary. | |
| createTemporaryFile () | |
| Creates a temporary file in this folder. | |
| assureExists () | |
| Throws an exception if this folder does not exist. | |
| isEmpty () | |
| Checks whether this folder contains any files or folders. | |
| delete () | |
| Deletes this folder from the file system including anything in it. | |
| moveTo ($folder, $overwrite, $newName=NULL) | |
| Moves this folder into another directory (and optionally renames it). | |
| exists () | |
| Whether this node already exists in the file system. | |
| residesIn (spunQ_IFolder $folder) | |
| Checks whether this file is in given folder or one of its subfolders. | |
| isReadable () | |
| Whether the node is readable. | |
| getPath () | |
| Returns the path pointing to the node. | |
| getPrettyPath () | |
| Returns the most unique and human-readable path. | |
| getContainingFolder () | |
| Returns the folder this node is residing in. | |
| getName () | |
| Returns the name of this node, deprived of its path. | |
| getLastAccessTime () | |
| Returns the time of last access of this node. | |
| getLastModificationTime () | |
| Returns the time of last modification of this node. | |
| __toString () | |
| Returns getPrettyPath(). | |
Static Public Member Functions | |
| static | current () |
| Provides the spunQ_Folder object of the folder calling file is in. | |
| static | getByAlias ($alias, $throwException=true) |
| Allows access to configured folders. | |
| static | _init () |
| Initializes the class. | |
| static | _shutdown () |
| Deletes all temporary folders. | |
| static | get ($path) |
| Factory method. | |
| static | isHidden ($path) |
| Whether a path indicates a hidden node (one that starts with a dot). | |
| static | getSysTmp () |
| Gets the systems temporary folder. | |
| static | createTemporaryFolder () |
| Creates a temporary folder. | |
| static | pathIsAbsolute ($filePath) |
| Tests if a givebn file path is absolute or relative. | |
| static | prettifyPath ($path) |
| Makes transformations to a path string to make it more readable. | |
Protected Attributes | |
| $path | |
| The path pointing to the node. | |
Private Member Functions | |
| getFilesWithAliasRecursiveImplementation ($path, $prefix, $suffixRegex, &$newest) | |
| Helper function for getFilesWithAliasRecursive(). | |
Static Private Member Functions | |
| static | getFilesRecursiveImplementation ($path, $suffixRegex, &$newest) |
| Helper function for getFilesRecursive(). | |
Static Private Attributes | |
| static | $temporaryFolders = array() |
| Array of temporary folders that will be removed on shutdown. | |
Definition at line 7 of file Folder.class.php.
| spunQ_FileNode::__toString | ( | ) | [inherited] |
| static spunQ_Folder::_init | ( | ) | [static] |
Initializes the class.
Just registers a shutdown hook to delete temporary folders.
Definition at line 42 of file Folder.class.php.
| static spunQ_Folder::_shutdown | ( | ) | [static] |
| spunQ_Folder::assureExists | ( | ) |
Throws an exception if this folder does not exist.
| spunQ_IOException |
Implements spunQ_IFolder.
Definition at line 276 of file Folder.class.php.
| spunQ_Folder::create | ( | ) |
Makes sure this folder exists - creating parent folders if necessary.
Doesn't do anything if the node already exists.
Implements spunQ_IFolder.
Definition at line 257 of file Folder.class.php.
| spunQ_Folder::createTemporaryFile | ( | ) |
Creates a temporary file in this folder.
| spunQ_IOException |
Implements spunQ_IFolder.
Definition at line 269 of file Folder.class.php.
| static spunQ_Folder::createTemporaryFolder | ( | ) | [static] |
Creates a temporary folder.
The folder will have a random name.
Definition at line 91 of file Folder.class.php.
| static spunQ_Folder::current | ( | ) | [static] |
Provides the spunQ_Folder object of the folder calling file is in.
You can use this function to get the folder you're currently in, if you want a file relative to that one. Makes use of spunQ_Backtrace.
Definition at line 15 of file Folder.class.php.
| spunQ_Folder::delete | ( | ) |
Deletes this folder from the file system including anything in it.
Implements spunQ_IFolder.
Definition at line 298 of file Folder.class.php.
| spunQ_FileNode::exists | ( | ) | [inherited] |
Whether this node already exists in the file system.
It is perfectly valid for an object to describe a non-existent node.
Implements spunQ_IFileNode.
Definition at line 78 of file FileNode.class.php.
| static spunQ_Folder::get | ( | $ | path | ) | [static] |
Factory method.
Creates a folder object that will operate on the given path.
| $path | A string describing a path on the file system |
Definition at line 64 of file Folder.class.php.
| spunQ_Folder::getBreadcrumbsTo | ( | spunQ_IFileNode $ | node | ) |
Does the same as getPathTo(), merely the result has a different format.
| $node | Another file node. |
Implements spunQ_IFolder.
Definition at line 250 of file Folder.class.php.
| static spunQ_Folder::getByAlias | ( | $ | alias, | |
| $ | throwException = true | |||
| ) | [static] |
Allows access to configured folders.
Any configuration value with a key that starts with spunQ.folder.
| $alias | Last part of the configuration key. | |
| $throwException | Whether an exception should be thrown if no such key was configured. |
Definition at line 29 of file Folder.class.php.
| spunQ_FileNode::getContainingFolder | ( | ) | [inherited] |
Returns the folder this node is residing in.
Implements spunQ_IFileNode.
Definition at line 127 of file FileNode.class.php.
| spunQ_Folder::getFile | ( | $ | name | ) |
Gets a file in - or relative to - this folder.
Note that this function does not ensure that the file actually exists. This can be achieved by a later call to exists() or create().
| $name | A string describing a file relative to this folder. |
Implements spunQ_IFolder.
Definition at line 211 of file Folder.class.php.
| spunQ_Folder::getFiles | ( | $ | includeHidden = true |
) |
Fetches all files in this folder.
| $includeHidden | Whether hidden files should be returned, too. |
Implements spunQ_IFolder.
Definition at line 163 of file Folder.class.php.
| spunQ_Folder::getFilesBySuffix | ( | $ | suffix, | |
| $ | includeHidden = true | |||
| ) |
Get all files in this folder with given suffix.
| $suffix | Either a suffix string or an array of suffixes. Not dot is prepended to the suffix, so if this value is 'ml', all files ending on 'html' will match, too. Whether to return hidden files. |
Implements spunQ_IFolder.
Definition at line 152 of file Folder.class.php.
| spunQ_Folder::getFilesRecursive | ( | array $ | suffixes, | |
| &$ | newest | |||
| ) |
Gets all files with any of the given suffixes in the folder recursively.
This function is optimized for speed, so it will not return objects.
| $folder | The folder to search in. Sub-folders of this folder will be processed recursively. | |
| $suffixes | List of file suffixes. Any file having one of the suffixes matches and will be returned. | |
| $newest | Out-parameter containing the highest mtime (last modification time) value of all returned files and each folder that was processed in recursive calls. This value will be used to verify the validity of caches holding the result of this function. |
Implements spunQ_IFolder.
Definition at line 117 of file Folder.class.php.
| static spunQ_Folder::getFilesRecursiveImplementation | ( | $ | path, | |
| $ | suffixRegex, | |||
| &$ | newest | |||
| ) | [static, private] |
Helper function for getFilesRecursive().
Takes the parameters in an optimized form and loops.
| $path | The string path of the file to process. | |
| $suffixRegex | A regex that will match files with the desired suffixes. | |
| $newest | Most recently modified file's timestamp. |
RecursiveIteratorIterator, glob and regular expressions and found the regular expressions to be the fastest by a great margin. Definition at line 362 of file Folder.class.php.
| spunQ_Folder::getFilesWithAliasRecursive | ( | array $ | suffixes, | |
| &$ | newest, | |||
| $ | alias | |||
| ) |
Almost the same as getFilesRecursive(), but generates aliases as well.
The alias consists of three parts, which are separated by dots:
$spunQFolder->getFilesRecursive(array('.class.php'), $newest, 'spunQ') was called. | $suffixes | List of file suffixes. Any file having one of the suffixes matches and will be returned. | |
| $newest | Out-parameter containing the highest mtime (last modification time) value of all returned files and each folder that was processed in recursive calls. This value will be used to verify the validity of caches holding the result of this function. | |
| $alias | Alias for all files in this folder. This should be the module name, or a similar top-level string. |
Implements spunQ_IFolder.
Definition at line 126 of file Folder.class.php.
| spunQ_Folder::getFilesWithAliasRecursiveImplementation | ( | $ | path, | |
| $ | prefix, | |||
| $ | suffixRegex, | |||
| &$ | newest | |||
| ) | [private] |
Helper function for getFilesWithAliasRecursive().
Takes the parameters in an optimized form and loops.
| $path | The string path of the file to process. | |
| $prefix | The string to prepend to each file. Will contain a trailing dot if it is not the empty string. | |
| $suffixRegex | A regex that will match files with the desired suffixes. | |
| $newest | Most recently modified file's timestamp. |
Definition at line 390 of file Folder.class.php.
| spunQ_Folder::getFolder | ( | $ | name | ) |
Gets a folder in - or relative to - this folder.
Note that this function does not ensure that the folder actually exists. This can be achieved by a later call to exists() or create().
| $name | A string describing a folder relative to this folder. |
Implements spunQ_IFolder.
Definition at line 218 of file Folder.class.php.
| spunQ_Folder::getFolders | ( | $ | includeHidden = true |
) |
Fetches all sub-folders in this folder.
| $includeHidden | Whether hidden folders should be returned, too. |
Implements spunQ_IFolder.
Reimplemented in spunQ_SourceFolder.
Definition at line 187 of file Folder.class.php.
| spunQ_FileNode::getLastAccessTime | ( | ) | [inherited] |
Returns the time of last access of this node.
| spunQ_IOException | If the timestamp could not be read. |
Implements spunQ_IFileNode.
Definition at line 141 of file FileNode.class.php.
| spunQ_FileNode::getLastModificationTime | ( | ) | [inherited] |
Returns the time of last modification of this node.
| spunQ_IOException | If the timestamp could not be read. |
Implements spunQ_IFileNode.
Definition at line 151 of file FileNode.class.php.
| spunQ_FileNode::getName | ( | ) | [inherited] |
Returns the name of this node, deprived of its path.
Implements spunQ_IFileNode.
Definition at line 134 of file FileNode.class.php.
| spunQ_Folder::getParent | ( | ) |
Alias for getContainingFolder().
Implements spunQ_IFolder.
Definition at line 110 of file Folder.class.php.
| spunQ_FileNode::getPath | ( | ) | [inherited] |
Returns the path pointing to the node.
Implements spunQ_IFileNode.
Definition at line 102 of file FileNode.class.php.
| spunQ_Folder::getPathTo | ( | spunQ_IFileNode $ | node | ) |
Will give the path from this folder to another file node.
| $node | Another file node. |
Implements spunQ_IFolder.
Definition at line 225 of file Folder.class.php.
| spunQ_FileNode::getPrettyPath | ( | ) | [inherited] |
Returns the most unique and human-readable path.
If the file exists, the builtin function realpath() is used. Otherwise, a better-looking path is achieved through string manipulation, i.e. '../a/../d/./' becomes '../d/'.
Implements spunQ_IFileNode.
Definition at line 109 of file FileNode.class.php.
| static spunQ_Folder::getSysTmp | ( | ) | [static] |
Gets the systems temporary folder.
Definition at line 82 of file Folder.class.php.
| spunQ_Folder::isEmpty | ( | ) |
Checks whether this folder contains any files or folders.
Implements spunQ_IFolder.
Definition at line 286 of file Folder.class.php.
| static spunQ_Folder::isHidden | ( | $ | path | ) | [static] |
Whether a path indicates a hidden node (one that starts with a dot).
| $path | An arbitrary file path. |
Definition at line 73 of file Folder.class.php.
| spunQ_FileNode::isReadable | ( | ) | [inherited] |
Whether the node is readable.
Implements spunQ_IFileNode.
Definition at line 95 of file FileNode.class.php.
| spunQ_Folder::moveTo | ( | $ | folder, | |
| $ | overwrite, | |||
| $ | newName = NULL | |||
| ) |
Moves this folder into another directory (and optionally renames it).
| $folder | the folder to move to. Either a spunQ_IFolder or a string. | |
| $overwrite | Whether the destination folder should be overwritten. Warning: The destination folder will be replaced(!), not extended. | |
| $newName | The folder will be renamed, too if this is set. |
Implements spunQ_IFolder.
Definition at line 317 of file Folder.class.php.
| static spunQ_FileNode::pathIsAbsolute | ( | $ | filePath | ) | [static, inherited] |
Tests if a givebn file path is absolute or relative.
| $filePath | The file path - a string. |
Definition at line 14 of file FileNode.class.php.
| static spunQ_FileNode::prettifyPath | ( | $ | path | ) | [static, inherited] |
Makes transformations to a path string to make it more readable.
Removes references to current and upper directories (/foo/.. or foo/.), for example. Assumes that the path has a slash as delimiter. if you want to use this function on a windows path, make sure to replace backslashes by forward slashes beforehand.
| $path | The path string to transform. |
Definition at line 34 of file FileNode.class.php.
| spunQ_FileNode::residesIn | ( | spunQ_IFolder $ | folder | ) | [inherited] |
Checks whether this file is in given folder or one of its subfolders.
| $folder | The folder to test against. |
Implements spunQ_IFileNode.
Definition at line 85 of file FileNode.class.php.
spunQ_FileNode::$path [protected, inherited] |
spunQ_Folder::$temporaryFolders = array() [static, private] |
Array of temporary folders that will be removed on shutdown.
Definition at line 105 of file Folder.class.php.
1.5.9