io
Packages
Interfaces
Classes
Files

Class: File

Source Location: /io/filesystem/file.class.php [line 47]

Class Overview

FileSystemElement
   |
   --File
This class represents a text file which can be read and written.

Author(s):



Class Details

This class represents a text file which can be read and written.

Tags:

[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]


Class Methods

constructor File [line 55]

File File( string $path, [int $mode = READ_WRITE], [bool $whenopen = OPEN_AFTER])
Builds a File object.

Parameters:

string   $path   Path of the file you want to work with.
int   $mode   If you want to open it only to read it, use the flag READ, if it's to write it use the WRITE flag, you also can use the READ_WRITE flag.
bool   $whenopen   If you want to open the file now, use the OPEN_NOW constant, if you want to open it only when you will need it, use the OPEN_AFTER constant.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method close [line 215]

void close( )
Closes a file and frees the allocated memory relative to the file.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method delete [line 229]

void delete( )
Deletes the file.
Overrides FileSystemElement::delete() (Deletes the element)
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method finclude [line 294]

true finclude( [bool $once = true])
Includes the file. Executes its PHP content here. Equivalent to the PHP include function.

Tags:

  • return: if the file has been successfully included

Parameters:

bool   $once   true if you don't want to include it if it has already been included.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method flush [line 280]

void flush( )
forces a write of all buffered output.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method frequire [line 311]

true frequire( [bool $once = true])
Requires the file. Executes its PHP content here. Equivalent to the PHP require function.

Tags:

  • return: if the file has been successfully included

Parameters:

bool   $once   true if you don't want to include it if it has already been included.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method get_contents [line 112]

string get_contents( [int $start = 0], [int $len = -1])
Returns the content of the file.

Tags:

  • return: The read content.

Parameters:

int   $start   Byte from which you want to start. 0 if you want to read the file from its begening, 1 to start with the second etc.
int   $len   Number of bytes you want to read.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method get_last_access_date [line 331]

int get_last_access_date( )
Returns the last access date of the file.

Tags:

  • return: The UNIX timestamp corresponding to the last access date of the file.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method get_last_modification_date [line 322]

int get_last_modification_date( )
Returns the date of the last modification of the file.

Tags:

  • return: The UNIX timestamp corresponding to the last modification date.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method get_lines [line 143]

string[] get_lines( [int $start = 0], [ $n = -1], int $len)
Returns the content of the file grouped by lines.

Tags:

  • return: The list of the lines of the file.

Parameters:

int   $start   Byte from which you want to start. 0 if you want to read the file from its begening, 1 to start with the second etc.
int   $len   Number of bytes you want to read.
   $n  
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method is_open [line 245]

bool is_open( )
Allows you to know if the file is already open.

Tags:

  • return: true if the file is open, false if it's closed.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method lock [line 254]

void lock( [bool $blocking = true])
Locks the file (it won't be readable by another thread which could try to access it).

Parameters:

bool   $blocking   if true, block the script, if false, non blocking operation
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method open [line 84]

void open( )
Opens the file. You cannot read or write a closed file, use this method to open it.
Overrides FileSystemElement::open() (Opens the file system element.)
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method unlock [line 267]

void unlock( )
Unlocks a file. The file must have been locked before you call this method.
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

method write [line 175]

bool write( string $data, [ $how = ERASE], [bool $mode = CLOSEFILE], bool $what)
Writes some text in the file.

Tags:

  • return: True if it could write, false otherwise.
Overrides FileSystemElement::write() (Does the necessary treatment to apply at each writing operation)

Parameters:

string   $data   The text you want to write in the file.
bool   $what   ERASE if you want to erase the file, ADD if you want to write at the end of the file.
bool   $mode   CLOSEFILE if you want to close the file before to write in it, NOTCLOSEFILE otherwise.
   $how  
[ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]


Class Variables

[line 345]   string  $contents 

Tags:

    [ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]
    [line 355]   File  $fd 

    Tags:

      [ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]
      [line 340]   string[]  $lines  = array()

      Tags:

        [ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]
        [line 350]   int  $mode 

        Tags:

          [ Top ] - [ Class Details ] - [ Methods ] - [ Variables ]

          Inherited Methods

          Class: FileSystemElement

          FileSystemElement::FileSystemElement()
          Builds a FileSystemElement object from the path of the element.
          FileSystemElement::change_chmod()
          Changes the chmod of the element.
          FileSystemElement::delete()
          Deletes the element
          FileSystemElement::exists()
          Allows you to know if the file system element exists.
          FileSystemElement::get()
          Initializes the file system element just before to be read.
          FileSystemElement::get_name()
          Returns the element name.
          FileSystemElement::open()
          Opens the file system element.
          FileSystemElement::write()
          Does the necessary treatment to apply at each writing operation


          Documentation generated on Tue, 28 Jul 2009 22:43:37 +0200 by phpDocumentor 1.4.1