File/file-defs.php

Description
Classes
Class Description
 class inputfile The inputfile class manages files for input. It opens, reads and closes files in input-only mode.
 class csv_inputfile CSV Inputfile class Manage CSV-formatted files for input.
 class stylesheet Open a file which contains a stylesheet and read in the style settings. This is a special case of inputfile.
 class outputfile The outputfile class manages files for outputting content. This includes both appending to an existing file, and creating new files. The method used in both cases is to write to a temporary file, and then rename/move it onto the final file path when closefile() is called.
 class quickfile This is a derived class from outputfile and is a quick way of creating a file with content in a single hit. You can check the $created property afterwards to determine success/failure.
 class quickfile_read This is a derived class from inputfile and is a quick way of grabbing all content of a file in a single hit. The resulting string is available as the class 'content' variable, and the variable 'readok' indicates whether the read was a success. File is read, then immediately closed.
 class fileupload Fileupload class.
 class configfile A generic system configuration file. Extend this for particular types of config file, such as .INI, shell definitions etc. Automatically calls the import_settings() method on instantiation.
 class shellconfigfile A system configuration file in the form of a shell script. These are in the standard NAME=VALUE format, but implemented as 'sh' scripts so that other scripts can use them via '.'. This class is provided to allow Php scripts to easily access the config settings in these too.
 class iniconfigfile A system configuration file in the form of an INI file. These are in the standard NAME=VALUE format, within sections. In this class we ignore the [sections], and just read in all of the NAME=VALUE pairs, stashing them into the 'settings' class var as an array.
Constants
ABANDON_FILE = 1 (line 33)

Abandon file on close

SAVE_FILE = (line 31)

Save the file on close

UPLOAD_E_ACCESS = 104 (line 716)

Destination directory access problem

UPLOAD_E_BADTYP = 102 (line 712)

Uploaded file was not of an allowed mime type

UPLOAD_E_HACK = 103 (line 714)

Attempt to move a non-uploaded file. Hacking.

UPLOAD_E_MAXSIZ = 101 (line 710)

Uploaded file exceeded the given maximum size

UPLOAD_E_MOV = 100 (line 708)

Failed to move file, filesys error (perms?)

UPLOAD_E_OK = (line 706)

Error code: All ok, no errors

Functions
file_get_contents (line 60)

Finally got around to implementing this file content reader for backward compatibility. (Kudos to Nigel McNie). This function file_get_contents will return the entire file as a string.

void file_get_contents (mixed $filename)
get_dirlist (line 135)

Returns an array containing full paths to the files in the directory

given by the path. This can be optionally recursive, in which case we will end up with a long list of path/filenames which comprise the whole tree, minus the special files '.' and '..'

  • return: List of full paths that comprise files in the directory, or tree
array get_dirlist (string $path, [boolean $recurse = false], [$regex $regex = ""])
  • string $path: Path to the directory containing the files to list
  • boolean $recurse: Whether to recurse the tree listing files in subdirs
  • $regex $regex: Full regular expression filename must match, eg: '/^.*?\.jpg$/i'
get_file_extn (line 101)

Return the file extension from a filepath.

void get_file_extn (mixed $path)
get_file_stem (line 114)

Return the file stem (name without extn) from a filepath.

void get_file_stem (mixed $path)
mkpath (line 73)

Make sure path exists A utility function which makes sure a given directory path is made, using mkdir as required. This function assumes that permissions are all as needed.

void mkpath (string $path)
  • string $path: The directory path which must exist
unique_filename (line 45)

Return a random unique filename, with optional prefix and an optional extension. The filename is composed from an md5 of microtime(), plus the prefix and extension if given.

  • return: Unique filename string
string unique_filename ([string $prefix = ""], [string $extn = ""])
  • string $prefix: Optional fixed prefix required.
  • string $extn: Optional fixed extension required.

Documentation generated by phpDocumentor 1.3.0RC3