system/io/UnixFileSystem.php

Show: inherited
Table of Contents

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  
Package
phing.system.io  
Version
$Id$  

\UnixFileSystem

Package: phing\system\io

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

Parent(s)
\FileSystem
Author
Andreas Aderhold, andi@binarycloud.com  
Version
$Id$  

Constants

Constantint  BA_EXISTS = 0x01
inherited

Inherited from: \FileSystem::BA_EXISTS
Inherited_from
\FileSystem::BA_EXISTS  
int
Constantint  BA_REGULAR = 0x02
inherited

Inherited from: \FileSystem::BA_REGULAR
Inherited_from
\FileSystem::BA_REGULAR  
int
Constantint  BA_DIRECTORY = 0x04
inherited

Inherited from: \FileSystem::BA_DIRECTORY
Inherited_from
\FileSystem::BA_DIRECTORY  
int
Constantint  BA_HIDDEN = 0x08
inherited

Inherited from: \FileSystem::BA_HIDDEN
Inherited_from
\FileSystem::BA_HIDDEN  
int

Properties

Propertyprivate\FileSystem  $fs= ''
staticinherited

Instance for getFileSystem() method.

Inherited from: \FileSystem::$$fs
Details
Type
\FileSystem
Inherited_from
\FileSystem::$$fs  

Methods

methodpubliccanDelete( \PhingFile $f ) : boolean

Whether file can be deleted.

Parameters
Name Type Description
$f \PhingFile
Returns
Type Description
boolean
methodpubliccanonicalize( string $strPath ) : mixed
inherited

canonicalize filename by checking on disk

Inherited from: \FileSystem::canonicalize()
Parameters
Name Type Description
$strPath string
Returns
Type Description
mixed Canonical path or false if the file doesn't exist.
methodpubliccheckAccess( \PhingFile $f, boolean $write = false ) : void
inherited

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.

Inherited from: \FileSystem::checkAccess()
Parameters
Name Type Description
$f \PhingFile
$write boolean
methodpublicchgrp( string $pathname, string $group ) : void
inherited

Change the group on a file or directory.

Inherited from: \FileSystem::chgrp()
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

Throws
Exception Description
\IOException if operation failed.
methodpublicchmod( string $pathname, int $mode ) : void
inherited

Change the permissions on a file or directory.

Inherited from: \FileSystem::chmod()
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.

Throws
Exception Description
\IOException if operation failed.
methodpublicchown( string $pathname, string $user ) : void
inherited

Change the ownership on a file or directory.

Inherited from: \FileSystem::chown()
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

Throws
Exception Description
\Exception if operation failed.
methodpubliccompare( \PhingFile $f1, \PhingFile $f2 ) : void

compares file paths lexicographically

Parameters
Name Type Description
$f1 \PhingFile
$f2 \PhingFile
methodpubliccompareMTimes( \file1 $file1, \file2 $file2 ) : \Int.
inherited

Compare the modified time of two files.

Inherited from: \FileSystem::compareMTimes()
Parameters
Name Type Description
$file1 \file1

String. Path and name of file1.

$file2 \file2

String. Path and name of file2.

Returns
Type Description
\Int. 1 if file1 is newer. -1 if file2 is newer. 0 if files have the same time. Err object on failure.
Throws
Exception Description
\Exception - if cannot get modified time of either file.
methodpubliccopy( \PhingFile $src, \PhingFile $dest ) : void

Copy a file, takes care of symbolic links

Parameters
Name Type Description
$src \PhingFile

Source path and name file to copy.

$dest \PhingFile

Destination path and name of new file.

Throws
Exception Description
\Exception if file cannot be copied.
methodpubliccopyr( string $source, string $dest ) : bool
inherited

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

Inherited from: \FileSystem::copyr()
Parameters
Name Type Description
$source string

Source path

$dest string

Destination path

Returns
Type Description
bool Returns TRUE on success, FALSE on failure
Details
Author
Aidan Lister  
Link
http://aidanlister.com/repos/v/function.copyr.php  
Version
1.0.1  
methodpubliccreateDirectory( \PhingFile $f, int $mode = 0755 ) : boolean
inherited

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

Inherited from: \FileSystem::createDirectory()

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

Parameters
Name Type Description
$f \PhingFile
$mode int
Returns
Type Description
boolean
methodpubliccreateNewFile( string $strPathname ) : boolean
inherited

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.

Inherited from: \FileSystem::createNewFile()
Parameters
Name Type Description
$strPathname string

Path of the file to be created.

Returns
Type Description
boolean
Throws
Exception Description
\IOException
methodpublicdelete( \PhingFile $f, boolean $recursive = false ) : void
inherited

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

Inherited from: \FileSystem::delete()
Parameters
Name Type Description
$f \PhingFile
$recursive boolean
methodpublicdeleteOnExit( \PhingFile $f ) : void
inherited

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.

Inherited from: \FileSystem::deleteOnExit()
Parameters
Name Type Description
$f \PhingFile
Throws
Exception Description
\IOException
methodpublicfromURIPath(  $p ) : void

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
Name Type Description
$p
methodpublicgetBooleanAttributes( \PhingFile $f ) : void

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
methodpublicgetDefaultParent( ) : void

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.

methodpublicgetFileSystem( ) : \FileSystem
staticinherited

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

Inherited from: \FileSystem::getFileSystem()
Returns
Type Description
\FileSystem
Throws
Exception Description
\IOException
methodpublicgetLastModifiedTime( \PhingFile $f ) : int
inherited

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.

Inherited from: \FileSystem::getLastModifiedTime()
Parameters
Name Type Description
$f \PhingFile
Returns
Type Description
int
Throws
Exception Description
\IOException
methodpublicgetLength( \PhingFile $f ) : int
inherited

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.

Inherited from: \FileSystem::getLength()
Parameters
Name Type Description
$f \PhingFile
Returns
Type Description
int
Throws
Exception Description
\IOException
methodpublicgetPathSeparator( ) : void

returns OS dependant directory separator char

methodpublicgetSeparator( ) : void

returns OS dependant path separator char

methodpublicisAbsolute( \PhingFile $f ) : void

Tell whether or not the given abstract pathname is absolute.

Parameters
Name Type Description
$f \PhingFile
methodpubliclistDir( \PhingFile $f ) : void
inherited

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.

Inherited from: \FileSystem::listDir()
Parameters
Name Type Description
$f \PhingFile
methodpubliclistRoots( ) : void

List the available filesystem roots, return array of PhingFile objects

Throws
Exception Description
\IOException
methodpubliclister(  $f ) : void

returns the contents of a directory in an array

Parameters
Name Type Description
$f
methodpubliclock( \PhingFile $f ) : void
inherited

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

Inherited from: \FileSystem::lock()
Parameters
Name Type Description
$f \PhingFile
Throws
Exception Description
\Exception
methodpublicnormalize(  $strPathname ) : void

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.

Parameters
Name Type Description
$strPathname
methodprotectednormalizer(  $pathname,  $len,  $offset ) : void

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

Parameters
Name Type Description
$pathname
$len
$offset
methodpublicprefixLength( string $pathname ) : void

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

Parameters
Name Type Description
$pathname string
methodpublicrename( \PhingFile $f1, \PhingFile $f2 ) : void
inherited

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.

Inherited from: \FileSystem::rename()
Parameters
Name Type Description
$f1 \PhingFile

abstract source file

$f2 \PhingFile

abstract destination file

Throws
Exception Description
\IOException if rename cannot be performed
methodpublicresolve( string $parent, string $child ) : void

Resolve the child pathname string against the parent.

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

Parameters
Name Type Description
$parent string
$child string
methodpublicresolveFile( \PhingFile $f ) : void

the file resolver

Parameters
Name Type Description
$f \PhingFile
methodpublicrmdir( \dir $dir, \children $children = false ) : void
inherited

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

Inherited from: \FileSystem::rmdir()
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.

methodpublicsetLastModifiedTime( \PhingFile $f, int $time ) : void
inherited

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.

Inherited from: \FileSystem::setLastModifiedTime()
Parameters
Name Type Description
$f \PhingFile
$time int
Throws
Exception Description
\IOException
methodpublicsetReadOnly( \PhingFile $f ) : void

set file readonly on unix

Parameters
Name Type Description
$f \PhingFile
Throws
Exception Description
\IOException
methodpublicsymlink( string $target, string $link ) : void
inherited

Symbolically link a file to another name.

Inherited from: \FileSystem::symlink()

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.

methodpublictouch( string $file, int $time = null ) : void
inherited

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

Inherited from: \FileSystem::touch()
Parameters
Name Type Description
$file string

Path and/or name of file to touch.

$time int
methodpublicumask( \mode $mode ) : void
inherited

Set the umask for file and directory creation.

Inherited from: \FileSystem::umask()
Parameters
Name Type Description
$mode \mode

Int. Permissions ususally in ocatal. Use leading 0 for octal. Number between 0 and 0777.

Throws
Exception Description
\Exception if there is an error performing operation.
methodpublicunlink( string $file ) : void
inherited

Delete a file.

Inherited from: \FileSystem::unlink()
Parameters
Name Type Description
$file string

Path and/or name of file to delete.

Throws
Exception Description
\IOException - if an error is encountered.
methodpublicunlock( \PhingFile $f ) : void
inherited

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

Inherited from: \FileSystem::unlock()
Parameters
Name Type Description
$f \PhingFile
Throws
Exception Description
\IOException
Documentation was generated by DocBlox 0.18.1.