phing-system-io

# Class: UnixFileSystem Source Location: /system/io/UnixFileSystem.php
### Class Overview
    FileSystem
       |
       --UnixFileSystem
UnixFileSystem class. This class encapsulates the basic file system functions for platforms using the unix (posix)-stylish filesystem. It wraps php native functions suppressing normal PHP error reporting and instead uses Exception to report and error. #### Author(s): Andreas Aderhold, andi@binarycloud.com #### Version: $Revision: 552 $ | ### Methods canDelete compare copy fromURIPath getBooleanAttributes getDefaultParent getPathSeparator getSeparator isAbsolute lister listRoots normalize normalizer prefixLength resolve resolveFile setReadOnly
### Inherited Constants #### Class: FileSystem FileSystem::BA_DIRECTORY FileSystem::BA_EXISTS FileSystem::BA_HIDDEN FileSystem::BA_REGULAR | ### Inherited Methods #### Class: FileSystem FileSystem::canDelete() Whether file can be deleted. FileSystem::canonicalize() canonicalize filename by checking on disk FileSystem::checkAccess() Check whether the file or directory denoted by the given abstract FileSystem::chmod() Change the permissions on a file or directory. FileSystem::chown() Change the ownership on a file or directory. FileSystem::compare() Compare two abstract pathnames lexicographically. FileSystem::compareMTimes() Compare the modified time of two files. FileSystem::copy() Copy a file. FileSystem::createDirectory() Create a new directory denoted by the given abstract pathname, returning true if and only if the operation succeeds. FileSystem::createNewFile() Create a new empty file with the given pathname. Return true if the file was created and false if a file or directory with the given pathname already exists. Throw an IOException if an I/O error occurs. FileSystem::delete() Delete the file or directory denoted by the given abstract pathname, returning true if and only if the operation succeeds. FileSystem::deleteOnExit() Arrange for the file or directory denoted by the given abstract pathname to be deleted when Phing::shutdown is called, returning true if and only if the operation succeeds. FileSystem::fromURIPath() Post-process the given URI path string if necessary. This is used on win32, e.g., to transform "/c:/foo" into "c:/foo". The path string still has slash separators; code in the PhingFile class will translate them after this method returns. FileSystem::getBooleanAttributes() Return the simple boolean attributes for the file or directory denoted by the given abstract pathname, or zero if it does not exist or some other I/O error occurs. FileSystem::getDefaultParent() Return the parent pathname string to be used when the parent-directory argument in one of the two-argument PhingFile constructors is the empty pathname. FileSystem::getFileSystem() Static method to return the FileSystem singelton representing this platform's local filesystem driver. FileSystem::getLastModifiedTime() Return the time at which the file or directory denoted by the given abstract pathname was last modified, or zero if it does not exist or some other I/O error occurs. FileSystem::getLength() Return the length in bytes of the file denoted by the given abstract pathname, or zero if it does not exist, is a directory, or some other I/O error occurs. FileSystem::getPathSeparator() Return the local filesystem's path-separator character. FileSystem::getSeparator() Return the local filesystem's name-separator character. FileSystem::isAbsolute() Tell whether or not the given abstract pathname is absolute. FileSystem::listDir() List the elements of the directory denoted by the given abstract pathname. Return an array of strings naming the elements of the directory if successful; otherwise, return null . FileSystem::listRoots() List the available filesystem roots, return array of PhingFile objects FileSystem::lock() Locks a file and throws an Exception if this is not possible. FileSystem::normalize() Convert the given pathname string to normal form. If the string is already in normal form then it is simply returned. FileSystem::prefixLength() Compute the length of this pathname string's prefix. The pathname string must be in normal form. FileSystem::rename() Rename the file or directory denoted by the first abstract pathname to the second abstract pathname, returning true if and only if the operation succeeds. FileSystem::resolve() Resolve the child pathname string against the parent. FileSystem::resolveFile() Resolve the given abstract pathname into absolute form. Invoked by the getAbsolutePath and getCanonicalPath methods in the PhingFile class. FileSystem::rmdir() Delete an empty directory OR a directory and all of its contents. FileSystem::setLastModifiedTime() Set the last-modified time of the file or directory denoted by the given abstract pathname returning true if and only if the operation succeeds. FileSystem::setReadOnly() Mark the file or directory denoted by the given abstract pathname as read-only, returning true if and only if the operation succeeds. FileSystem::symlink() Symbolically link a file to another name. FileSystem::touch() Set the modification and access time on a file to the present time. FileSystem::umask() Set the umask for file and directory creation. FileSystem::unlink() Delete a file. FileSystem::unlock() Unlocks a file and throws an IO Error if this is not possible.
### Class Details [line 45] UnixFileSystem class. This class encapsulates the basic file system functions for platforms using the unix (posix)-stylish filesystem. It wraps php native functions suppressing normal PHP error reporting and instead uses Exception to report and error. This class is part of a oop based filesystem abstraction and targeted to run on all supported php platforms. Note: For debugging turn track_errors on in the php.ini. The error messages and log messages from this class will then be clearer because $php_errormsg is passed as part of the message. FIXME: Comments Error handling reduced to min, error are handled by PhingFile mainly #### Tags:
author: | Andreas Aderhold, andi@binarycloud.com
version: | $Revision: 552 $
[ Top ] ### Class Methods ### method canDelete [line 299]
`boolean canDelete( PhingFile $f)`
Whether file can be deleted. Overrides FileSystem::canDelete() (Whether file can be deleted.) #### Parameters:
PhingFile | $f |
[ Top ] ### method compare [line 217]
`void compare( $f1, $f2)`
compares file paths lexicographically Overrides FileSystem::compare() (Compare two abstract pathnames lexicographically.) #### Parameters:
| $f1 |
| $f2 |
[ Top ] ### method copy [line 236]
`void copy( PhingFile $src, PhingFile $dest)`
Copy a file, takes care of symbolic links #### Tags:
throws: | Exception if file cannot be copied.
Overrides FileSystem::copy() (Copy a file.) #### Parameters:
PhingFile | $src | Source path and name file to copy.
PhingFile | $dest | Destination path and name of new file.
[ Top ] ### method fromURIPath [line 283]
`void fromURIPath( $p)`
Overrides FileSystem::fromURIPath() (Post-process the given URI path string if necessary. This is used on win32, e.g., to transform "/c:/foo" into "c:/foo". The path string still has slash separators; code in the PhingFile class will translate them after this method returns.) #### Parameters:
| $p |
[ Top ] ### method getBooleanAttributes [line 194]
`void getBooleanAttributes( &$f)`
Overrides FileSystem::getBooleanAttributes() (Return the simple boolean attributes for the file or directory denoted by the given abstract pathname, or zero if it does not exist or some other I/O error occurs.) #### Parameters:
| &$f |
[ Top ] ### method getDefaultParent [line 171]
`void getDefaultParent( )`
Overrides FileSystem::getDefaultParent() (Return the parent pathname string to be used when the parent-directory argument in one of the two-argument PhingFile constructors is the empty pathname.) [ Top ] ### method getPathSeparator [line 57]
`void getPathSeparator( )`
returns OS dependant directory separator char Overrides FileSystem::getPathSeparator() (Return the local filesystem's path-separator character.) [ Top ] ### method getSeparator [line 50]
`void getSeparator( )`
returns OS dependant path separator char Overrides FileSystem::getSeparator() (Return the local filesystem's name-separator character.) [ Top ] ### method isAbsolute [line 175]
`void isAbsolute( PhingFile $f)`
Overrides FileSystem::isAbsolute() (Tell whether or not the given abstract pathname is absolute.) #### Parameters:
PhingFile | $f |
[ Top ] ### method lister [line 267]
`void lister( $f)`
returns the contents of a directory in an array #### Parameters:
| $f |
[ Top ] ### method listRoots [line 257]
`void listRoots( )`
Overrides FileSystem::listRoots() (List the available filesystem roots, return array of PhingFile objects) [ Top ] ### method normalize [line 69]
`void normalize( $strPathname)`
A normal Unix pathname contains no duplicate slashes and does not end with a slash. It may be the empty string. Check that the given pathname is normal. If not, invoke the real normalizer on the part of the pathname that requires normalization. This way we iterate through the whole pathname string only once. Overrides FileSystem::normalize() (Convert the given pathname string to normal form. If the string is already in normal form then it is simply returned.) #### Parameters:
| $strPathname |
[ Top ] ### method normalizer [line 107]
`void normalizer( $pathname, $len, $offset)`
Normalize the given pathname, whose length is $len, starting at the given $offset; everything before this offset is already normal. #### Tags:
access: | protected
#### Parameters:
| $pathname |
| $len |
| $offset |
[ Top ] ### method prefixLength [line 139]
`void prefixLength( $pathname)`
Compute the length of the pathname string's prefix. The pathname string must be in normal form. Overrides FileSystem::prefixLength() (Compute the length of this pathname string's prefix. The pathname string must be in normal form.) #### Parameters:
| $pathname |
[ Top ] ### method resolve [line 151]
`void resolve( $parent, $child)`
Resolve the child pathname string against the parent. Both strings must be in normal form, and the result will be in normal form. Overrides FileSystem::resolve() (Resolve the child pathname string against the parent.) #### Parameters:
| $parent |
| $child |
[ Top ] ### method resolveFile [line 182]
`void resolveFile( PhingFile $f)`
the file resolver Overrides FileSystem::resolveFile() (Resolve the given abstract pathname into absolute form. Invoked by the getAbsolutePath and getCanonicalPath methods in the PhingFile class.) #### Parameters:
PhingFile | $f |
[ Top ] ### method setReadOnly [line 204]
`void setReadOnly( $f)`
set file readonly on unix Overrides FileSystem::setReadOnly() (Mark the file or directory denoted by the given abstract pathname as read-only, returning true if and only if the operation succeeds.) #### Parameters:
| $f |
[ Top ] Documentation generated on Mon, 19 Oct 2009 10:52:18 +0200 by phpDocumentor 1.4.3