[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/file/ -> file.class.php (sommaire)

\defgroup File The File module provides some classes to deal with files. The File class is the most useful once, since provides OOP wrappers around some PHP functions that work with files.

Poids: 499 lignes (14 kb)
Inclus ou requis:0 fois
Référencé: 8 fois
Nécessite: 0 fichiers

Définit 1 class

File:: (24 méthodes):
  File()
  open()
  close()
  readFile()
  read()
  eof()
  write()
  truncate()
  writeLines()
  isDir()
  isWritable()
  isReadable()
  delete()
  deleteDir()
  createDir()
  chDir()
  getTempName()
  getSize()
  rename()
  copy()
  chMod()
  exists()
  touch()
  basename()


Classe: File  - X-Ref

\ingroup File

Encapsulation of a class to manage files. It is basically a wrapper
to some of the php functions.
http://www.php.net/manual/en/ref.filesystem.php
File( $fileName )   X-Ref
Creates an object of this type, but the file is not automaticaly
opened

param: fileName The name of the file

open( $mode = "r" )   X-Ref
Opens the file in the specified mode
http://www.php.net/manual/en/function.fopen.php
Mode by default is 'r' (read only)
Returns 'false' if operation failed

param: mode The mode in which the file is opened
return: false if the operation failed

close()   X-Ref
Closes the stream currently being held by this object

return: nothing

readFile()   X-Ref
Reads the whole file and put it into an array, where every position
of the array is a line of the file (new-line characters not
included)

return: An array where every position is a line from the file.

read( $size = 4096 )   X-Ref
Reads bytes from the currently opened file

param: size Amount of bytes we'd like to read from the file. It is
return: Returns the read contents

eof()   X-Ref
checks whether we've reached the end of file

return: True if we reached the end of the file or false otherwise

write( $data )   X-Ref
Writes data to disk

param: data The data that we'd like to write to disk
return: returns the number of bytes written, or false otherwise

truncate( $length = 0 )   X-Ref
truncates the currently opened file to a given length

param: length Lenght at which we'd like to truncate the file
return: true if successful or false otherwise

writeLines( $lines )   X-Ref
Writes an array of text lines to the file.

param: lines The array with the text.
return: Returns true if successful or false otherwise.

isDir( $file = null )   X-Ref
Returns true wether the file is a directory. See
http://fi.php.net/manual/en/function.is-dir.php for more details.

param: file The filename we're trying to check. If omitted, the
return: Returns true if the file is a directory.

isWritable( $file = null )   X-Ref
Returns true if the file is writable by the current user.
See http://fi.php.net/manual/en/function.is-writable.php for more
details.

param: file The filename we're trying to check. If omitted, the
return: Returns true if the file is writable, or false otherwise.

isReadable( $file = null )   X-Ref
returns true if the file is readable. Can be used as static if a
filename is provided

param: if provided, this method can be used as an static method and
return: true if readable or false otherwise

delete( $file = null )   X-Ref
removes a file. Can be used as static if a filename is provided.
Otherwise it will remove the file that was given in the constructor

param: optionally, name of the file to delete
return: True if successful or false otherwise

deleteDir( $dirName, $recursive = false, $onlyFiles = false, $excludedFiles = array('')   X-Ref
removes a directory, optinally in a recursive fashion

param: dirName
param: recursive Whether to recurse through all subdirectories that
param: onlyFiles If the recursive mode is enabled, setting this to 'true' will
param: excludedFiles If some files or directories should not be removed (like .htaccess) they can be added
return: True if successful or false otherwise

createDir( $dirName, $mode = FILE_DEFAULT_DIRECTORY_CREATION_MODE )   X-Ref
Creates a new folder. If the folder name is /a/b/c and neither
/a or /a/b exist, this method will take care of creating the
whole folder structure automatically.

param: dirName The name of the new folder
param: mode Attributes that will be given to the folder
return: Returns true if no problem or false otherwise.

chDir( $dir )   X-Ref
Change the current directory

param: dir

getTempName()   X-Ref
returns a temporary filename in a pseudo-random manner

return: a temporary name

getSize( $fileName = null )   X-Ref
Returns the size of the file.

param: string fileName An optional parameter specifying the name
return: An integer specifying the size of the file.

rename( $inFile, $outFile = null )   X-Ref
renames a file

http://www.php.net/manual/en/function.rename.php

This function can be used as static if inFile and outFile are both
not empty. if outFile is empty, then the internal file of the
current object will be used as the input file and the first
parameter of this method will become the destination file name.

param: inFile Original file
param: outFile Destination file.
return: Returns true if file was renamed ok or false otherwise.

copy( $inFile, $outFile )   X-Ref
copies a file from one place to another.
This method is always static

param: inFile
param: destFile
return: True if successful or false otherwise

chMod( $inFile, $mode = 0644 )   X-Ref
changes the permissions of a file, via PHP's chmod() function

param: inFile The name of the file whose mode we'd like to change
param: mode The new mode, or if none provided, it will default
return: true if successful or false otherwise

exists( $fileName = null )   X-Ref
returns true if the file exists.

Can be used as an static method if a file name is provided as a
parameter
param: fileName optinally, name of the file whose existance we'd
return: true if successful or false otherwise

touch( $fileName = null )   X-Ref
returns true if the file could be touched

Can be used to create a file or to reset the timestamp.
return: true if successful or false otherwise

basename( $fileName = null )   X-Ref
returns the basename of a file

return: basename of the file



Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics