UnixFileSystem

Extends \FileSystem

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
author

Andreas Aderhold, andi@binarycloud.com

version

$Id: 6902c2574836413d625f5d74f8156f5774c74fd9 $

package

phing.system.io

Methods

Whether file can be deleted.

canDelete(\PhingFile $f) : boolean
inherited

Arguments

Response

boolean

canonicalize filename by checking on disk

canonicalize(string $strPath) : mixed
inherited

Arguments

$strPath

string

Response

mixed

Canonical path or false if the file doesn't exist.

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.

checkAccess(\PhingFile $f, boolean $write = false) 
inherited

Arguments

$write

boolean

Change the group on a file or directory.

chgrp(string $pathname, string $group) : void
inherited
throws

if operation failed.

Arguments

$pathname

string

Path and name of file or directory.

$group

string

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

Change the permissions on a file or directory.

chmod(string $pathname, integer $mode) : void
inherited
throws

if operation failed.

Arguments

$pathname

string

Path and name of file or directory.

$mode

integer

The mode (permissions) of the file or

                     directory. If using octal add leading 0. eg. 0777.
                     Mode is affected by the umask system setting.

Change the ownership on a file or directory.

chown(string $pathname, string $user) : void
inherited
throws

if operation failed.

Arguments

$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

Compare two abstract pathnames lexicographically.

compare(\PhingFile $f1, \PhingFile $f2) 
inherited

Arguments

Compare the modified time of two files.

compareMTimes( $file1,  $file2) : \Int.
inherited
throws
  • if cannot get modified time of either file.

Arguments

$file1

$file2

Response

\Int.

1 if file1 is newer.

            -1 if file2 is newer.
             0 if files have the same time.
             Err object on failure.

Copy a file.

copy(\PhingFile $src, \PhingFile $dest) : void
inherited
throws

if file cannot be copied.

Arguments

$src

\PhingFile

Source path and name file to copy.

$dest

\PhingFile

Destination path and name of new file.

Copy a file, or recursively copy a folder and its contents

copyr(string $source, string $dest) : boolean
inherited
author

Aidan Lister aidan@php.net

version 1.0.1
link

http://aidanlister.com/repos/v/function.copyr.php

Arguments

$source

string

Source path

$dest

string

Destination path

Response

boolean

Returns TRUE on success, FALSE on failure

Create a new directory denoted by the given abstract pathname, returning true if and only if the operation succeeds.

createDirectory(\PhingFile &$f, integer $mode = 493) : boolean
inherited

NOTE: umask() is reset to 0 while executing mkdir(), and restored afterwards

Arguments

$mode

integer

Response

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.

createNewFile(string $strPathname) : boolean
inherited
throws

Arguments

$strPathname

string

Path of the file to be created.

Response

boolean

Delete the file or directory denoted by the given abstract pathname, returning true if and only if the operation succeeds.

delete(\PhingFile $f, boolean $recursive = false) : void
inherited

Arguments

$recursive

boolean

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.

deleteOnExit(\PhingFile $f) 
inherited
throws

Arguments

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.

fromURIPath(string $path) 
inherited abstract

Arguments

$path

string

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.

getBooleanAttributes(\PhingFile $f) 
inherited

Arguments

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.

getDefaultParent() 
inherited abstract

Static method to return the FileSystem singelton representing this platform's local filesystem driver.

getFileSystem() : \FileSystem
inherited static
throws

Response

\FileSystem

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.

getLastModifiedTime(\PhingFile $f) : integer
inherited
throws

Arguments

Response

integer

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.

getLength(\PhingFile $f) : integer
inherited
throws

Arguments

Response

integer

Return the local filesystem's path-separator character.

getPathSeparator() 
inherited abstract

Return the local filesystem's name-separator character.

getSeparator() 
inherited abstract

Tell whether or not the given abstract pathname is absolute.

isAbsolute(\PhingFile $f) 
inherited abstract

Arguments

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 <code>null</code>.

listDir(\PhingFile $f) 
inherited

Arguments

returns the contents of a directory in an array

lister( $f) 

Arguments

$f

List the available filesystem roots, return array of PhingFile objects

listRoots() 
inherited
throws

Locks a file and throws an Exception if this is not possible.

lock(\PhingFile $f) : void
inherited
throws

Arguments

Convert the given pathname string to normal form. If the string is already in normal form then it is simply returned.

normalize(string $strPath) 
inherited abstract

Arguments

$strPath

string

Normalize the given pathname, whose length is $len, starting at the given $offset; everything before this offset is already normal.

normalizer( $pathname,  $len,  $offset) 

Arguments

$pathname

$len

$offset

Compute the length of this pathname string's prefix. The pathname string must be in normal form.

prefixLength(string $pathname) 
inherited abstract

Arguments

$pathname

string

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.

rename(\PhingFile $f1, \PhingFile $f2) : void
inherited
throws

if rename cannot be performed

Arguments

$f1

\PhingFile

abstract source file

$f2

\PhingFile

abstract destination file

Resolve the child pathname string against the parent.

resolve(string $parent, string $child) 
inherited abstract

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

Arguments

$parent

string

$child

string

Resolve the given abstract pathname into absolute form. Invoked by the getAbsolutePath and getCanonicalPath methods in the PhingFile class.

resolveFile(\PhingFile $f) 
inherited abstract

Arguments

Delete an empty directory OR a directory and all of its contents.

rmdir( $dir,  $children = false) : void
inherited

Arguments

$dir

$children

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.

setLastModifiedTime(\PhingFile $f, integer $time) : void
inherited
throws

Arguments

$time

integer

Mark the file or directory denoted by the given abstract pathname as read-only, returning <code>true</code> if and only if the operation succeeds.

setReadOnly(\PhingFile $f) 
inherited
throws

Arguments

Set the modification and access time on a file to the present time.

touch(string $file, integer $time = null) : void
inherited

Arguments

$file

string

Path and/or name of file to touch.

$time

integer

Set the umask for file and directory creation.

umask( $mode) : void
inherited
throws

if there is an error performing operation.

Arguments

$mode

Unlocks a file and throws an IO Error if this is not possible.

unlock(\PhingFile $f) : void
inherited
throws

Arguments

Constants

BA_EXISTS

BA_EXISTS
inherited
var

BA_REGULAR

BA_REGULAR
inherited
var

BA_DIRECTORY

BA_DIRECTORY
inherited
var

BA_HIDDEN

BA_HIDDEN
inherited
var

Properties

Instance for getFileSystem() method.

fs : \FileSystem
inherited static
var

Type(s)

\FileSystem