File
[ class tree: File ] [ index: File ] [ all elements ]

Class: File

Source Location: /File-1.1.0RC1/File.php

Class Overview

PEAR
   |
   --File

Class for handling files


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 89]
Class for handling files

A class with common functions for writing, reading and handling files and directories



[ Top ]


Method Detail

buildPath   [line 456]

void buildPath( array $parts, [string $separator = DIRECTORY_SEPARATOR])

Returns a string path built from the array $pathParts. Where a join occurs multiple separators are removed. Joins using the optional separator, defaulting to the PHP DIRECTORY_SEPARATOR constant.
  • Access: public

Parameters:

array   $parts   —  Array containing the parts to be joined
string   $separator   —  The system directory seperator

[ Top ]

close   [line 405]

mixed close( string $filename, string $mode)

This closes an open file pointer
  • Return: PEAR Error on error, true otherwise
  • Access: public

Parameters:

string   $filename   —  The filename that was opened
string   $mode   —  Mode the file was opened in

[ Top ]

closeAll   [line 374]

void closeAll( )

Closes all open file pointers
  • Access: public

[ Top ]

getTempDir   [line 536]

string getTempDir( )

Returns the temp directory according to either the TMP, TMPDIR, or TEMP env variables. If these are not set it will also check for the existence of /tmp, %WINDIR%\temp
  • Return: The system tmp directory
  • Access: public

[ Top ]

getTempFile   [line 581]

string getTempFile( [string $dirname = null])

Returns a temporary filename using tempnam() and File::getTmpDir().
  • Return: Filename and path of the tmp file
  • Access: public

Parameters:

string   $dirname   —  Optional directory name for the tmp file

[ Top ]

isAbsolute   [line 596]

boolean isAbsolute( string $path)

Returns boolean based on whether given path is absolute or not.
  • Return: True if the path is absolute, false if it is not
  • Access: public

Parameters:

string   $path   —  Given path

[ Top ]

read   [line 218]

mixed read( string $filename, [integer $size = FILE_DEFAULT_READSIZE], [mixed $lock = false])

Returns a specified number of bytes of a file.

Defaults to FILE_DEFAULT_READSIZE. If $size is 0, all file will be read.

  • Return: PEAR_Error on error or a string which contains the data read Will also return false upon EOF
  • Access: public

Parameters:

string   $filename   —  Name of file to read from
integer   $size   —  Bytes to read
mixed   $lock   —  Type of lock to use

[ Top ]

readAll   [line 184]

mixed readAll( string $filename, [mixed $lock = false])

Reads an entire file and returns it.

Uses file_get_contents if available.

  • Return: PEAR_Error if an error has occured or a string with the contents of the the file
  • Access: public

Parameters:

string   $filename   —  Name of file to read from
mixed   $lock   —  Type of lock to use

[ Top ]

readChar   [line 270]

mixed readChar( string $filename, [mixed $lock = false])

Reads and returns a single character from given filename
  • Return: PEAR_Error on error or one character of the specified file
  • Access: public

Parameters:

string   $filename   —  Name of file to read from
mixed   $lock   —  Type of lock to use

[ Top ]

readLine   [line 305]

mixed readLine( string $filename, [boolean $lock = false])

Returns a line of the file (without trailing CRLF).

Maximum read line length is FILE_MAX_LINE_READSIZE.

  • Return: PEAR_Error on error or a string containing the line read from file
  • Access: public

Parameters:

string   $filename   —  Name of file to read from
boolean   $lock   —  Whether file should be locked

[ Top ]

realpath   [line 651]

string realpath( string $path, [string $separator = DIRECTORY_SEPARATOR])

Get real path (works with non-existant paths)
  • Access: public

Parameters:

string   $path   — 
string   $separator   — 

[ Top ]

relativePath   [line 617]

string relativePath( string $path, string $root, [string $separator = DIRECTORY_SEPARATOR])

Get path relative to another path
  • Access: public

Parameters:

string   $path   — 
string   $root   — 
string   $separator   — 

[ Top ]

rewind   [line 357]

mixed rewind( string $filename, string $mode)

This rewinds a filepointer to the start of a file
  • Return: PEAR Error on error, true on success
  • Access: public

Parameters:

string   $filename   —  The filename
string   $mode   —  Mode the file was opened in

[ Top ]

skipRoot   [line 516]

string skipRoot( string $path)

Returns a path without leading / or C:\. If this is not present the path is returned as is.
  • Return: The processed path or the path as is
  • Access: public

Parameters:

string   $path   —  The path to be processed

[ Top ]

stripLeadingSeparators   [line 502]

string stripLeadingSeparators( string $path, [string $separator = DIRECTORY_SEPARATOR])

Strips leading separators from the given path
  • Return: Resulting path
  • Deprecated:
  • Access: public

Parameters:

string   $path   —  Path to use
string   $separator   —  Separator to look for

[ Top ]

stripTrailingSeparators   [line 487]

string stripTrailingSeparators( string $path, [string $separator = DIRECTORY_SEPARATOR])

Strips trailing separators from the given path
  • Return: Resulting path
  • Deprecated:
  • Access: public

Parameters:

string   $path   —  Path to use
string   $separator   —  Separator to look for

[ Top ]

unlock   [line 436]

mixed unlock( string $filename, string $mode)

This unlocks a locked file pointer.
  • Return: PEAR Error on error, true otherwise
  • Access: public

Parameters:

string   $filename   —  The filename that was opened
string   $mode   —  Mode the file was opened in

[ Top ]

write   [line 251]

mixed write( string $filename, string $data, [string $mode = FILE_MODE_APPEND], [mixed $lock = false])

Writes the given data to the given filename.

Defaults to no lock, append mode.

  • Return: PEAR_Error on error or number of bytes written to file.
  • Access: public

Parameters:

string   $filename   —  Name of file to write to
string   $data   —  Data to write to file
string   $mode   —  Mode to open file in
mixed   $lock   —  Type of lock to use

[ Top ]

writeChar   [line 285]

mixed writeChar( string $filename, string $char, [string $mode = FILE_MODE_APPEND], [mixed $lock = false])

Writes a single character to a file
  • Return: PEAR_Error on error, or 1 on success
  • Access: public

Parameters:

string   $filename   —  Name of file to write to
string   $char   —  Character to write
string   $mode   —  Mode to use when writing
mixed   $lock   —  Type of lock to use

[ Top ]

writeLine   [line 338]

mixed writeLine( string $filename, string $line, [string $mode = FILE_MODE_APPEND], [string $crlf = "\n"], [mixed $lock = false])

Writes a single line, appending a LF (by default)
  • Return: PEAR_Error on error or number of bytes written to file (including appended crlf)
  • Access: public

Parameters:

string   $filename   —  Name of file to write to
string   $line   —  Line of data to be written to file
string   $mode   —  Write mode, can be either FILE_MODE_WRITE or FILE_MODE_APPEND
string   $crlf   —  The CRLF your system is using. UNIX = \n Windows = \r\n Mac = \r
mixed   $lock   —  Whether to lock the file

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:59:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.