FileUtils

File utility class.

  • handles os independent stuff etc
  • mapper stuff
  • filter stuff
package

phing.util

Methods

contentEquals

contentEquals(\PhingFile $file1, \PhingFile $file2) : boolean

Arguments

$file1

\PhingFile

$file2

\PhingFile

Response

boolean

Whether contents of two files is the same.

Copies a file using filter chains.

copyFile(\PhingFile $sourceFile, \PhingFile $destFile, \Project $project, boolean $overwrite = false, boolean $preserveLastModified = true, array &$filterChains = null, integer $mode = 493, boolean $preservePermissions = true) : void
Throws
\Exception
\IOException

Arguments

$sourceFile

\PhingFile

$destFile

\PhingFile

$project

\Project

$overwrite

boolean

$preserveLastModified

boolean

$filterChains

array

$mode

integer

$preservePermissions

boolean

Create a temporary file in a given directory.

createTempFile(string $prefix, string $suffix, \PhingFile $parentDir, boolean $deleteOnExit = false, boolean $createFile = false) : \PhingFile

The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent invocation of this method will yield a different file name.

Throws
\BuildException

Arguments

$prefix

string

prefix before the random number.

$suffix

string

file extension; include the '.'.

$parentDir

\PhingFile

Directory to create the temporary file in; sys_get_temp_dir() used if not specified.

$deleteOnExit

boolean

whether to set the tempfile for deletion on normal exit.

$createFile

boolean

true if the file must actually be created. If false chances exist that a file with the same name is created in the time between invoking this method and the moment the file is actually created. If possible set to true.

Response

\PhingFile

a File reference to the new temporary file.

Returns a new Reader with filterchains applied. If filterchains are empty, simply returns passed reader.

getChainedReader(\Reader $in,  &$filterChains, \Project $project) : \Reader
static

Arguments

$in

\Reader

Reader to modify (if appropriate).

$filterChains

$project

\Project

Response

\Reader

Assembled Reader (w/ filter chains).

Returns the default file/dir creation mask value (The mask value is prepared w.r.t the current user's file-creation mask value)

getDefaultFileCreationMask(boolean $dirmode = false) : integer
static

Arguments

$dirmode

boolean

Directory creation mask to select

Response

integer

Creation Mask in octal representation

Normalize the given absolute path.

normalize(string $path) : string

This includes:

  • Uppercase the drive letter if there is one.
  • Remove redundant slashes after the drive spec.
  • resolve all ./, .\, ../ and ..\ sequences.
  • DOS style paths that start with a drive letter will have \ as the separator.
Throws
\IOException

Arguments

$path

string

Path to normalize.

Response

string

Attempts to rename a file from a source to a destination.

renameFile(\PhingFile $sourceFile, \PhingFile $destFile,  $overwrite = false) : boolean

If overwrite is set to true, this method overwrites existing file even if the destination file is newer. Otherwise, the source file is renamed only if the destination file is older than it.

Arguments

$sourceFile

\PhingFile

$destFile

\PhingFile

$overwrite

Response

boolean

Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename.

resolveFile(\PhingFile $file, string $filename) : \PhingFile
Throws
\IOException

Arguments

$file

\PhingFile

the "reference" file for relative paths. This instance must be an absolute file and must not contain ./ or ../ sequences (same for \ instead of /).

$filename

string

a file name

Response

\PhingFile

A PhingFile object pointing to an absolute file that doesn't contain ./ or ../ sequences and uses the correct separator for the current platform.