ColdBox Platform Version 3.7.0

coldbox.system.core.util
Class FileUtils

WEB-INF.cftags.component
        extended by coldbox.system.core.util.FileUtils
Direct Known Subclasses:
FileUtils

public class FileUtils
extends WEB-INF.cftags.component

This is a File Utilities CFC


Method Summary
 void appendFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
          Facade to append to a file's content
 string checkCharSet(string charset)
          Check a charset with valid CF char sets, if invalid, it returns the framework's default character set
 void createFile(String filename)
          Create a new empty fileusing java
 void directoryCopy(string source, string destination)
          Copies an entire source directory to a destination directory
 void directoryCreate(string path='', [string mode='755'])
          Create a new directory
 void directoryNew(string path, string name)
          Creates a new directory on the file system
 void directoryRemove(string path='', [boolean recurse='true'])
          Remove an entire directory
 void directoryRename(string path, string name)
          Renames a directory on the file system
 boolean fileCanRead(String Filename)
          Check wether you can read a file
 boolean fileCanWrite(String Filename)
          Check wether you can write to a file
 string fileLastModified(string filename)
          Get the last modified date of a file
 string fileSize(string filename, [string sizeFormat='bytes'])
          Get the filesize of a file
 string getAbsolutePath(string path)
          Turn any system path, either relative or absolute, into a fully qualified one
 string getFileMimeType(string extension)
          Get's the file mime type for a given file extension
 boolean isDirectory(String Filename)
          Check wether the filename argument is a directory or not
 boolean isFile(String Filename)
          Checks whether the filename argument is a file or not
 Any readFile(String FileToRead, [boolean ReadInBinaryFlag='false'], [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
          Facade to Read a file's content
 boolean removeFile(string filename)
          Remove a file using java
 void renameFile(string path, string name)
          Renames a directory on the file system
 string ripExtension(string filename)
          Rip the extension of a filename
 void saveFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
          Facade to save a file's content
 void sendFile([any file=''], [string name=''], [string mimeType=''], [string disposition='attachment'], [boolean abortAtEnd='false'], [string extension=''], [string deleteFile='false'])
          Send a file to the browser
 any uploadFile(string fileField, string destination, [string nameConflict='makeunique'], [string accept=''], [string attributes='Normal'], [string mode='755'])
          Facade to upload to a file, returns the cffile variable
 
Methods inherited from class WEB-INF.cftags.component
 

Method Detail

appendFile

public void appendFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
Facade to append to a file's content

Parameters:
FileToSave - The absolute path to the file.
FileContents - The file contents
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

checkCharSet

public string checkCharSet(string charset)
Check a charset with valid CF char sets, if invalid, it returns the framework's default character set

Parameters:
charset - Charset to check

createFile

public void createFile(String filename)
Create a new empty fileusing java.io.File.

Parameters:
filename - The absolute path of the file to create.

directoryCopy

public void directoryCopy(string source, string destination)
Copies an entire source directory to a destination directory

Parameters:
source
destination

directoryCreate

public void directoryCreate(string path='', [string mode='755'])
Create a new directory

Parameters:
path - The full path to remove
mode - The mode of the file for Unix systems, the default is 755

directoryNew

public void directoryNew(string path, string name)
Creates a new directory on the file system.

Parameters:
path - The absolute path of the base directory. The new directory will be a sub-directory of this path.
name - The name of the new directory.

directoryRemove

public void directoryRemove(string path='', [boolean recurse='true'])
Remove an entire directory

Parameters:
path - The full path to remove
recurse - Recurse or not

directoryRename

public void directoryRename(string path, string name)
Renames a directory on the file system.

Parameters:
path - The absolute path of the directory. This directory will be renamed to the name argument.
name - The new name of the directory.

fileCanRead

public boolean fileCanRead(String Filename)
Check wether you can read a file

Parameters:
Filename - The absolute path of the file to check.

fileCanWrite

public boolean fileCanWrite(String Filename)
Check wether you can write to a file

Parameters:
Filename - The absolute path of the file to check.

fileLastModified

public string fileLastModified(string filename)
Get the last modified date of a file

Parameters:
filename

fileSize

public string fileSize(string filename, [string sizeFormat='bytes'])
Get the filesize of a file.

Parameters:
filename
sizeFormat - Available formats: [bytes][kbytes][mbytes][gbytes]

getAbsolutePath

public string getAbsolutePath(string path)
Turn any system path, either relative or absolute, into a fully qualified one

Parameters:
path - Abstract pathname

getFileMimeType

public string getFileMimeType(string extension)
Get's the file mime type for a given file extension

Parameters:
extension - e.g. jpg or gif

isDirectory

public boolean isDirectory(String Filename)
Check wether the filename argument is a directory or not

Parameters:
Filename - The absolute path of the file to check.

isFile

public boolean isFile(String Filename)
Checks whether the filename argument is a file or not.

Parameters:
Filename - The absolute path of the file to check.

readFile

public Any readFile(String FileToRead, [boolean ReadInBinaryFlag='false'], [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
Facade to Read a file's content

Parameters:
FileToRead - The absolute path to the file.
ReadInBinaryFlag - Read in binary flag.
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

removeFile

public boolean removeFile(string filename)
Remove a file using java.io.File

Parameters:
filename - The absolute path to the file.

renameFile

public void renameFile(string path, string name)
Renames a directory on the file system.

Parameters:
path - The absolute path of the file to rename
name - The new name of the file.

ripExtension

public string ripExtension(string filename)
Rip the extension of a filename.

Parameters:
filename

saveFile

public void saveFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
Facade to save a file's content

Parameters:
FileToSave - The absolute path to the file.
FileContents - The file contents
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

sendFile

public void sendFile([any file=''], [string name=''], [string mimeType=''], [string disposition='attachment'], [boolean abortAtEnd='false'], [string extension=''], [string deleteFile='false'])
Send a file to the browser

Parameters:
file - The absolute path to the file or a binary file
name - The name to send the file to the browser. If not sent in, it will use the name of the file or a UUID for a binary file
mimeType - A valid mime type to use. If not sent in, we will try to use a default one according to file extension
disposition - The browser content disposition (attachment/inline)
abortAtEnd - Do an abort after content sending
extension - Only used if file is binary. e.g. jpg or gif
deleteFile - Delete the file after sending. Only used if file is not binary

uploadFile

public any uploadFile(string fileField, string destination, [string nameConflict='makeunique'], [string accept=''], [string attributes='Normal'], [string mode='755'])
Facade to upload to a file, returns the cffile variable.

Parameters:
fileField - The name of the form field used to select the file
destination - The absolute path to the destination.
nameConflict - Action to take if filename is the same as that of a file in the directory.
accept - Limits the MIME types to accept. Comma-delimited list.
attributes - Comma-delimitted list of window file attributes
mode - The mode of the file for Unix systems, the default is 755

ColdBox Platform Version 3.7.0