Class FileFunctions

Description

A library for manipulating files, directories and paths

Located in /class.filefunctions.php (line 24)


                
			
Method Summary
static string CreateFileNameFromTime (string $sBase)
static string CreateRandomFileNameFromString (string $sBase, string $sString)
static string CreateTemporaryDirectory ()
static mixed FileExistsInPath (string $sFileName)
static string GetFileBaseName (string $sFileName)
static string GetFileExtension ( $sFilename, string $sFileName)
static string GetMimeType (string $sFileName)
static string HandleUploadedFile (string $sTmpFile, string $sUploadName, string $sDirectory)
static string HumanReadableSize (integer $iSizeInBytes)
static boolean MoveRecursively (string $sOldDirectory, string $sNewDirectory)
static boolean RemoveRecursively (string $sPath)
Methods
static method CreateFileNameFromTime (line 107)

This method takes the name of a file, and creates a new file name using microtime() as the file name, and the original file's extension as the extension.

  • return: The file name created from microtime
  • access: public
static string CreateFileNameFromTime (string $sBase)
  • string $sBase: The base file name to use as an example
static method CreateRandomFileNameFromString (line 127)

Similar to CreateFileNameFrom(), this method also accepts a string to append to the timestamp in order to help ensure a more unique name when files are created at the exact same time, or in rapid succession.

  • return: The name of the randomly generated file name
  • access: public
static string CreateRandomFileNameFromString (string $sBase, string $sString)
  • string $sBase: The name of the original file, used to get the file extension
  • string $sString: The string to add to the time to ensure a more unique name
static method CreateTemporaryDirectory (line 226)

Creates a temporary directory in the systems temporary directory (determined by the sys_get_temp_dir()). This directory name is the first 8 characters of the the md5 hash of the current microtime().

  • return: The name of the newly created temporary directory
  • access: public
static string CreateTemporaryDirectory ()
static method FileExistsInPath (line 171)

Attempts to find the specified file name in the include path. Loops each path in the include path, and, upon the first result, returns the absolute path to the file.

  • return: Returns the absolute path to the file, if found, or false if not
  • access: public
static mixed FileExistsInPath (string $sFileName)
  • string $sFileName: The file name to attempt to find in the include path
static method GetFileBaseName (line 50)

Determines the base name of a file by removing the directory structure before it, as well as the extension of the file. Passing /path/to/file.ext will return "file"

  • return: The base name of the file without path or extension
  • access: public
static string GetFileBaseName (string $sFileName)
  • string $sFileName: The name of the file
static method GetFileExtension (line 34)

Determines the file extension of the given file name. File extension is determined to be any characters after the last period (.)

  • return: The extension of the supplied file
  • access: public
static string GetFileExtension ( $sFilename, string $sFileName)
  • string $sFileName: The name of the file
  • $sFilename
static method GetMimeType (line 80)

Determines the mime type of the given file. This method uses the FileInfo extension of PHP and may not always be accurate in determining the mime type of all files. FileInfo must be installed for this to work properly.

  • return: The mime type of the supplied file
  • access: public
static string GetMimeType (string $sFileName)
  • string $sFileName: The name of the file
static method HandleUploadedFile (line 148)

This method takes information about an uploaded file through _FILES and gives the file a unique name using microtime() and the extension of the original file name, as well as moves that file from the temporary path to a specified folder.

  • return: The unique name of the file without the path.
  • access: public
static string HandleUploadedFile (string $sTmpFile, string $sUploadName, string $sDirectory)
  • string $sTmpFile: The absolute path to the temp file uploaded via _FILES
  • string $sUploadName: The name of the uploaded file to determine the file extension
  • string $sDirectory: The path to the directory to store the new file
static method HumanReadableSize (line 195)

Returns a human readable file size format in the form of #.## (bytes|KB|MB|GB)

  • return: A formated string of the file size
  • access: public
static string HumanReadableSize (integer $iSizeInBytes)
  • integer $iSizeInBytes: The file size in bytes
static method MoveRecursively (line 290)

Moves a specified directory to a new location, recursively. The need for this method arises from the fact that the native php rename() function cannot move files or directories across partitions on Windows systems.

  • return: True if the directory and it's contents were all moved successfully, false otherwise
  • access: public
static boolean MoveRecursively (string $sOldDirectory, string $sNewDirectory)
  • string $sOldDirectory: The directory to recursively move
  • string $sNewDirectory: The new directory to move the old directory to
static method RemoveRecursively (line 251)

Removes the specified directory and all of it's contents, recursively. The need for this method arises from the native php rmdir() not being able to delete a directory if there are files in it.

  • return: True if the directory was removed successfully, false otherwise
  • access: public
static boolean RemoveRecursively (string $sPath)
  • string $sPath: The name of the directory to remove (recursively)

Documentation generated on Thu, 25 Feb 2010 15:59:40 -0500 by phpDocumentor 1.4.3