classes/phing/system/io/FileSystem.php

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 exceptions more precise errorhandling is done by the PhingFile class

author
Charlie Killian
author
Hans Lellelid
package
phing.system.io
version
$Revision: 1260 $

\FileSystem

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 exceptions more precise errorhandling is done by the PhingFile class

author
Charlie Killian
author
Hans Lellelid
package
phing.system.io
version
$Revision: 1260 $

Constants

Constantint  BA_EXISTS = '0x01'

int
Constantint  BA_REGULAR = '0x02'

int
Constantint  BA_DIRECTORY = '0x04'

int
Constantint  BA_HIDDEN = '0x08'

int

Properties

Propertyprivate\FileSystem  $fs= ''
static

Instance for getFileSystem() method.

Details
Type
\FileSystem

Methods

methodpublic  canDelete( \PhingFile $f ) : boolean
Whether file can be deleted.
Parameters
Name Type Description
$f \PhingFile
Returns
Type Description
boolean
methodpublic  canonicalize( string $strPath ) : mixed
canonicalize filename by checking on disk
Parameters
Name Type Description
$strPath string
Returns
Type Description
mixed
methodpublic  checkAccess( \PhingFile $f, boolean $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
Name Type Description
$f \PhingFile
$write boolean
methodpublic  chgrp( string $pathname, string $group ) : void
Change the group on a file or directory.
Parameters
Name Type Description
$pathname string Path and name of file or directory.
$group string

The group of the file or directory. See http://us.php.net/chgrp

Details
throws
if operation failed.
methodpublic  chmod( string $pathname, int $mode ) : void
Change the permissions on a file or directory.
Parameters
Name Type Description
$pathname string Path and name of file or directory.
$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.

Details
throws
if operation failed.
methodpublic  chown( string $pathname, string $user ) : void
Change the ownership on a file or directory.
Parameters
Name Type Description
$pathname string Path and name of file or directory.
$user string

The user name or number of the file or directory. See http://us.php.net/chown

Details
throws
if operation failed.
methodpublic  compare( \PhingFile $f1, \PhingFile $f2 ) :
Compare two abstract pathnames lexicographically.
Parameters
Name Type Description
$f1 \PhingFile
$f2 \PhingFile
methodpublic  compareMTimes( \file1 $file1, \file2 $file2 ) : \Int.
Compare the modified time of two files.
Parameters
Name Type Description
$file1 \file1 String. Path and name of file1.
$file2 \file2 String. Path and name of file2.
Returns
Type Description
\Int.
Details
throws
- if cannot get modified time of either file.
methodpublic  copy( \PhingFile $src, \PhingFile $dest ) : void
Copy a file.
Parameters
Name Type Description
$src \PhingFile Source path and name file to copy.
$dest \PhingFile Destination path and name of new file.
Details
throws
if file cannot be copied.
methodpublic  copyr( string $source, string $dest ) : bool
Copy a file, or recursively copy a folder and its contents
Parameters
Name Type Description
$source string Source path
$dest string Destination path
Returns
Type Description
bool
Details
author
Aidan Lister
link
http://aidanlister.com/repos/v/function.copyr.php
version
1.0.1
methodpublic  createDirectory( \PhingFile $f, int $mode = 0755 ) : boolean
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
Name Type Description
$f \PhingFile
$mode int
Returns
Type Description
boolean
methodpublic  createNewFile( string $strPathname ) : boolean
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.
Parameters
Name Type Description
$strPathname string Path of the file to be created.
Returns
Type Description
boolean
Details
throws
methodpublic  delete( \PhingFile $f, boolean $recursive = false ) : void
Delete the file or directory denoted by the given abstract pathname, returning true if and only if the operation succeeds.
Parameters
Name Type Description
$f \PhingFile
$recursive boolean
methodpublic  deleteOnExit( \PhingFile $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
Name Type Description
$f \PhingFile
Details
throws
methodpublic  fromURIPath( string $path ) :
abstractPost-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
Name Type Description
$path string
methodpublic  getBooleanAttributes( \PhingFile $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.
Parameters
Name Type Description
$f \PhingFile
methodpublic  getDefaultParent( ) :
abstractReturn the parent pathname string to be used when the parent-directory argument in one of the two-argument PhingFile constructors is the empty pathname.
methodpublic  getFileSystem( ) : \FileSystem
staticStatic method to return the FileSystem singelton representing this platform's local filesystem driver.
Returns
Type Description
\FileSystem
Details
throws
methodpublic  getLastModifiedTime( \PhingFile $f ) : int
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
Name Type Description
$f \PhingFile
Returns
Type Description
int
Details
throws
methodpublic  getLength( \PhingFile $f ) : int
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
Name Type Description
$f \PhingFile
Returns
Type Description
int
Details
throws
methodpublic  getPathSeparator( ) :
abstractReturn the local filesystem's path-separator character.
methodpublic  getSeparator( ) :
abstractReturn the local filesystem's name-separator character.
methodpublic  isAbsolute( \PhingFile $f ) :
abstractTell whether or not the given abstract pathname is absolute.
Parameters
Name Type Description
$f \PhingFile
methodpublic  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
Name Type Description
$f \PhingFile
methodpublic  listRoots( ) :
List the available filesystem roots, return array of PhingFile objects
Details
throws
methodpublic  lock( \PhingFile $f ) : void
Locks a file and throws an Exception if this is not possible.
Parameters
Name Type Description
$f \PhingFile
Details
throws
methodpublic  normalize( string $strPath ) :
abstractConvert the given pathname string to normal form. If the string is already in normal form then it is simply returned.
Parameters
Name Type Description
$strPath string
methodpublic  prefixLength( string $pathname ) :
abstractCompute the length of this pathname string's prefix. The pathname string must be in normal form.
Parameters
Name Type Description
$pathname string
methodpublic  rename( \PhingFile $f1, \PhingFile $f2 ) : void
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.
Parameters
Name Type Description
$f1 \PhingFile abstract source file
$f2 \PhingFile abstract destination file
Details
throws
if rename cannot be performed
methodpublic  resolve( string $parent, string $child ) :
abstractResolve the child pathname string against the parent.

Both strings must be in normal form, and the result will be a string in normal form.

Parameters
Name Type Description
$parent string
$child string
methodpublic  resolveFile( \PhingFile $f ) :
abstractResolve the given abstract pathname into absolute form. Invoked by the getAbsolutePath and getCanonicalPath methods in the PhingFile class.
Parameters
Name Type Description
$f \PhingFile
methodpublic  rmdir( \dir $dir, \children $children = false ) : void
Delete an empty directory OR a directory and all of its contents.
Parameters
Name Type Description
$dir \dir

String. Path and/or name of directory to delete.

$children \children

Boolean. False: don't delete directory contents. True: delete directory contents.

methodpublic  setLastModifiedTime( \PhingFile $f, int $time ) : void
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.
Parameters
Name Type Description
$f \PhingFile
$time int
Details
throws
methodpublic  setReadOnly( \PhingFile $f ) :
Mark the file or directory denoted by the given abstract pathname as read-only, returning true if and only if the operation succeeds.
Parameters
Name Type Description
$f \PhingFile
Details
throws
methodpublic  symlink( string $target, string $link ) : void
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
Name Type Description
$target string

Path and/or name of file to link.

$link string

Path and/or name of link to be created.

methodpublic  touch( string $file, int $time = null ) : void
Set the modification and access time on a file to the present time.
Parameters
Name Type Description
$file string

Path and/or name of file to touch.

$time int
methodpublic  umask( \mode $mode ) : void
Set the umask for file and directory creation.
Parameters
Name Type Description
$mode \mode Int. Permissions ususally in ocatal. Use leading 0 for octal. Number between 0 and 0777.
Details
throws
if there is an error performing operation.
methodpublic  unlink( string $file ) : void
Delete a file.
Parameters
Name Type Description
$file string

Path and/or name of file to delete.

Details
throws
- if an error is encountered.
methodpublic  unlock( \PhingFile $f ) : void
Unlocks a file and throws an IO Error if this is not possible.
Parameters
Name Type Description
$f \PhingFile
Details
throws
Documentation was generated by DocBlox 0.13.1.