phing-system-io

# Class: FileSystem Source Location: /system/io/FileSystem.php
### Class Overview
This is an abstract class for platform specific filesystem implementations you have to implement each method in the platform specific filesystem implementation classes Your local filesytem implementation must extend this class. #### Author(s): Hans Lellelid <hans@xmpl.org> Charlie Killian <charlie@tizac.com> #### Version: $Revision: 552 $ | ### Constants BA_DIRECTORY BA_EXISTS BA_HIDDEN BA_REGULAR | ### Methods canDelete canonicalize checkAccess chmod chown compare compareMTimes copy createDirectory createNewFile delete deleteOnExit fromURIPath getBooleanAttributes getDefaultParent getFileSystem getLastModifiedTime getLength getPathSeparator getSeparator isAbsolute listDir listRoots lock normalize prefixLength rename resolve resolveFile rmdir setLastModifiedTime setReadOnly symlink touch umask unlink unlock
### Child classes: Win32FileSystem 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.
### Class Details [line 41] This is an abstract class for platform specific filesystem implementations you have to implement each method in the platform specific filesystem implementation classes Your local filesytem implementation must extend this class. You should also use this class as a template to write your local implementation Some native PHP filesystem specific methods are abstracted here as well. Anyway you _must_ always use this methods via a PhingFile object (that by nature uses the *FileSystem drivers to access the real filesystem via this class using natives. FIXME: Error handling reduced to min fallthrough runtime excetions more precise errorhandling is done by the PhingFile class #### Tags:
author: | Hans Lellelid <hans@xmpl.org>
author: | Charlie Killian <charlie@tizac.com>
version: | $Revision: 552 $
abstract: |
[ Top ] ### Class Methods ### static method getFileSystem [line 57]
`static FileSystem getFileSystem( )`
Static method to return the FileSystem singelton representing this platform's local filesystem driver. #### Tags:
access: | public
[ Top ] ### method canDelete [line 199]
`boolean canDelete( PhingFile $f)`
Whether file can be deleted. Overridden in child classes as: UnixFileSystem::canDelete() Whether file can be deleted. #### Parameters:
PhingFile | $f |
[ Top ] ### method canonicalize [line 142]
`mixed canonicalize( $strPath)`
canonicalize filename by checking on disk #### Tags:
return: | Canonical path or false if the file doesn't exist.
#### Parameters:
| $strPath |
[ Top ] ### method checkAccess [line 165]
`void checkAccess( PhingFile $f, [ $write = false])`
Check whether the file or directory denoted by the given abstract pathname may be accessed by this process. If the second argument is false, then a check for read access is made; if the second argument is true, then a check for write (not read-write) access is made. Return false if access is denied or an I/O error occurs. #### Parameters:
PhingFile | $f |
| $write |
[ Top ] ### method chmod [line 443]
`void chmod( pathname $pathname, mode $mode)`
Change the permissions on a file or directory. #### Tags:
throws: | Exception if operation failed.
#### Parameters:
pathname | $pathname | String. Path and name of file or directory.
mode | $mode | Int. The mode (permissions) of the file or directory. If using octal add leading 0. eg. 0777. Mode is affected by the umask system setting.
[ Top ] ### method chown [line 425]
`void chown( string $pathname, string $user)`
Change the ownership on a file or directory. #### Tags:
throws: | Exception if operation failed.
#### Parameters:
string | $pathname | Path and name of file or directory.
string | $user | The user name or number of the file or directory. See http://us.php.net/chown
[ Top ] ### method compare [line 384]
`void compare( $f1, $f2)`
Compare two abstract pathnames lexicographically. Overridden in child classes as: Win32FileSystem::compare() compares file paths lexicographically UnixFileSystem::compare() compares file paths lexicographically #### Parameters:
| $f1 |
| $f2 |
[ Top ] ### method compareMTimes [line 668]
`Int. compareMTimes( file1 $file1, file2 $file2)`
Compare the modified time of two files. #### Tags:
return: | 1 if file1 is newer. -1 if file2 is newer. if files have the same time. Err object on failure.
throws: | Exception - if cannot get modified time of either file.
#### Parameters:
file1 | $file1 | String. Path and name of file1.
file2 | $file2 | String. Path and name of file2.
[ Top ] ### method copy [line 397]
`void copy( PhingFile $src, PhingFile $dest)`
Copy a file. #### Tags:
throws: | Exception if file cannot be copied.
Overridden in child classes as: UnixFileSystem::copy() Copy a file, takes care of symbolic links #### Parameters:
PhingFile | $src | Source path and name file to copy.
PhingFile | $dest | Destination path and name of new file.
[ Top ] ### method createDirectory [line 319]
`void createDirectory( &$f, [ $mode = 0755])`
Create a new directory denoted by the given abstract pathname, returning true if and only if the operation succeeds. NOTE: umask() is reset to 0 while executing mkdir(), and restored afterwards #### Parameters:
| &$f |
| $mode |
[ Top ] ### method createNewFile [line 257]
`void createNewFile( string $strPathname)`
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. #### Tags:
throws: | IOException
#### Parameters:
string | $strPathname | Path of the file to be created.
[ Top ] ### method delete [line 274]
`void delete( PhingFile $f)`
Delete the file or directory denoted by the given abstract pathname, returning true if and only if the operation succeeds. #### Parameters:
PhingFile | $f |
[ Top ] ### method deleteOnExit [line 287]
`void deleteOnExit( $f)`
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. #### Parameters:
| $f |
[ Top ] ### method fromURIPath [line 129]
`void fromURIPath( $path)`
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. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::fromURIPath() UnixFileSystem::fromURIPath() #### Parameters:
| $path |
[ Top ] ### method getBooleanAttributes [line 153]
`void getBooleanAttributes( $f)`
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. Overridden in child classes as: UnixFileSystem::getBooleanAttributes() #### Parameters:
| $f |
[ Top ] ### method getDefaultParent [line 121]
`void 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. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::getDefaultParent() UnixFileSystem::getDefaultParent() [ Top ] ### method getLastModifiedTime [line 211]
`void getLastModifiedTime( PhingFile $f)`
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. #### Parameters:
PhingFile | $f |
[ Top ] ### method getLength [line 234]
`void getLength( PhingFile $f)`
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. #### Parameters:
PhingFile | $f |
[ Top ] ### method getPathSeparator [line 89]
`void getPathSeparator( )`
Return the local filesystem's path-separator character. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::getPathSeparator() UnixFileSystem::getPathSeparator() returns OS dependant directory separator char [ Top ] ### method getSeparator [line 84]
`void getSeparator( )`
Return the local filesystem's name-separator character. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::getSeparator() UnixFileSystem::getSeparator() returns OS dependant path separator char [ Top ] ### method isAbsolute [line 136]
`void isAbsolute( PhingFile $f)`
Tell whether or not the given abstract pathname is absolute. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::isAbsolute() UnixFileSystem::isAbsolute() #### Parameters:
PhingFile | $f |
[ Top ] ### method listDir [line 296]
`void listDir( PhingFile $f)`
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 . #### Parameters:
PhingFile | $f |
[ Top ] ### method listRoots [line 375]
`void listRoots( )`
List the available filesystem roots, return array of PhingFile objects Overridden in child classes as: Win32FileSystem::listRoots() UnixFileSystem::listRoots() [ Top ] ### method lock [line 456]
`void lock( PhingFile $f)`
Locks a file and throws an Exception if this is not possible. #### Tags:
throws: | Exception
#### Parameters:
PhingFile | $f |
[ Top ] ### method normalize [line 95]
`void normalize( $strPath)`
Convert the given pathname string to normal form. If the string is already in normal form then it is simply returned. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::normalize() Check that the given pathname is normal. If not, invoke the real normalizer on the part of the pathname that requires normalization. UnixFileSystem::normalize() A normal Unix pathname contains no duplicate slashes and does not end with a slash. It may be the empty string. #### Parameters:
| $strPath |
[ Top ] ### method prefixLength [line 101]
`void prefixLength( $pathname)`
Compute the length of this pathname string's prefix. The pathname string must be in normal form. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::prefixLength() UnixFileSystem::prefixLength() Compute the length of the pathname string's prefix. The pathname string must be in normal form. #### Parameters:
| $pathname |
[ Top ] ### method rename [line 336]
`void rename( PhingFile $f1, PhingFile $f2)`
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. #### Tags:
throws: | Exception if rename cannot be performed
#### Parameters:
PhingFile | $f1 | abstract source file
PhingFile | $f2 | abstract destination file
[ Top ] ### method resolve [line 108]
`void resolve( $parent, $child)`
Resolve the child pathname string against the parent. Both strings must be in normal form, and the result will be a string in normal form. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::resolve() UnixFileSystem::resolve() Resolve the child pathname string against the parent. #### Parameters:
| $parent |
| $child |
[ Top ] ### method resolveFile [line 114]
`void resolveFile( PhingFile $f)`
Resolve the given abstract pathname into absolute form. Invoked by the getAbsolutePath and getCanonicalPath methods in the PhingFile class. #### Tags:
abstract: |
Overridden in child classes as: Win32FileSystem::resolveFile() UnixFileSystem::resolveFile() the file resolver #### Parameters:
PhingFile | $f |
[ Top ] ### method rmdir [line 552]
`void rmdir( dir $dir, [children $children = false])`
Delete an empty directory OR a directory and all of its contents. #### Parameters:
dir | $dir | String. Path and/or name of directory to delete.
children | $children | Boolean. False: don't delete directory contents. True: delete directory contents.
[ Top ] ### method setLastModifiedTime [line 353]
`void setLastModifiedTime( PhingFile $f, $time)`
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. #### Tags:
throws: | Exception
#### Parameters:
PhingFile | $f |
| $time |
[ Top ] ### method setReadOnly [line 366]
`void setReadOnly( $f)`
Mark the file or directory denoted by the given abstract pathname as read-only, returning true if and only if the operation succeeds. Overridden in child classes as: Win32FileSystem::setReadOnly() UnixFileSystem::setReadOnly() set file readonly on unix #### Parameters:
| $f |
[ Top ] ### method symlink [line 507]
`void symlink( string $target, string $link)`
Symbolically link a file to another name. Currently symlink is not implemented on Windows. Don't use if the application is to be portable. #### Parameters:
string | $target | Path and/or name of file to link.
string | $link | Path and/or name of link to be created.
[ Top ] ### method touch [line 527]
`void touch( string $file, [int $time = null])`
Set the modification and access time on a file to the present time. #### Parameters:
string | $file | Path and/or name of file to touch.
int | $time |
[ Top ] ### method umask [line 639]
`void umask( mode $mode)`
Set the umask for file and directory creation. #### Tags:
throws: | Exception if there is an error performing operation.
#### Parameters:
mode | $mode | Int. Permissions ususally in ocatal. Use leading 0 for octal. Number between 0 and 0777.
[ Top ] ### method unlink [line 490]
`void unlink( file $file)`
Delete a file. #### Tags:
throws: | Exception - if an error is encountered.
#### Parameters:
file | $file | String. Path and/or name of file to delete.
[ Top ] ### method unlock [line 472]
`void unlock( PhingFile $f)`
Unlocks a file and throws an IO Error if this is not possible. #### Tags:
throws: | Exception
#### Parameters:
PhingFile | $f |
[ Top ] ### Class Constants #### BA_DIRECTORY = 0x04 [line 46] [ Top ] #### BA_EXISTS = 0x01 [line 44] [ Top ] #### BA_HIDDEN = 0x08 [line 47] [ Top ] #### BA_REGULAR = 0x02 [line 45] [ Top ] Documentation generated on Mon, 19 Oct 2009 10:50:58 +0200 by phpDocumentor 1.4.3