Moai SDK  2.0
MOAIFileSystem Class Reference
+ Inheritance diagram for MOAIFileSystem:

Function List

affirmPath
 
checkFileExists
 
checkPathExists
 
copy
 
deleteDirectory
 
deleteFile
 
getAbsoluteDirectoryPath
 
getAbsoluteFilePath
 
getRelativePath
 
getWorkingDirectory
 
getVirtualPathInfo
 
listDirectories
 
listFiles
 
loadFile
 
mountVirtualDirectory
 
rename
 
saveFile
 
setWorkingDirectory
 
stripPKZipTimestamps
 

Function Documentation

affirmPath

Creates a folder at 'path' if none exists.


function affirmPath ( string path )

Parameters
stringpath
Returns
nil
checkFileExists

Check for the existence of a file.


function checkFileExists ( string filename )

Parameters
stringfilename
Returns
boolean exists
checkPathExists

Check for the existence of a path.


function checkPathExists ( string path )

Parameters
stringpath
Returns
boolean exists
copy

Copy a file or directory to a new location.


function copy ( string srcPath, string destPath )

Parameters
stringsrcPath
stringdestPath
Returns
boolean result
deleteDirectory

Deletes a directory and all of its contents.


function deleteDirectory ( string path [, boolean recursive ] )

Parameters
stringpath
booleanrecursive Optional. If true, the directory and all contents beneath it will be purged. Otherwise, the directory will only be removed if empty.
Returns
boolean success
deleteFile

Deletes a file.


function deleteFile ( string filename )

Parameters
stringfilename
Returns
boolean success
getAbsoluteDirectoryPath

Returns the absolute path given a relative path.


function getAbsoluteDirectoryPath ( string path )

Parameters
stringpath
Returns
string absolute
getAbsoluteFilePath

Returns the absolute path to a file. Result includes the file name.


function getAbsoluteFilePath ( string filename )

Parameters
stringfilename
Returns
string absolute
getRelativePath

Given an absolute path returns the relative path in relation to the current working directory or a user supplied 'base' directory.


function getRelativePath ( string path [, string base ] )

Parameters
stringpath
stringbase Optional.
Returns
string path
getVirtualPathInfo

Given a virtual path, return the path to the archive and, if the path is to a file, the offset to the file record within the archive.


function getVirtualPathInfo ( string path [, string offsetToHeader, number uncompressedSize, number compressedSize ] )

Parameters
stringpath A virtual path.
stringoffsetToHeader Optional. Offset to the file record header in the archive, or nil if not a file path.
numberuncompressedSize Optional. Uncompressed size of the file or nil if not a file path.
numbercompressedSize Optional. Compressed size of the file or nil if not compressed or not a file path.
Returns
string pathToArchive, string localPath
getWorkingDirectory

Returns the path to current working directory.


function getWorkingDirectory ()

Returns
string path
listDirectories

Lists the sub-directories contained in a directory.


function listDirectories ( [ string path ] )

Parameters
stringpath Optional. Path to search. Default is current directory.
Returns
table directories
listFiles

Lists the files contained in a directory.


function listFiles ( [ string path ] )

Parameters
stringpath Optional. Path to search. Default is current directory.
Returns
table files
loadFile

Open and read the entirity of a file into a string.


function loadFile ( string filename )

Parameters
stringfilename
Returns
string contents
mountVirtualDirectory

Mount an archive as a virtual filesystem directory.


function mountVirtualDirectory ( string path [, string archive ] )

Parameters
stringpath Virtual path.
stringarchive Optional. Name of archive file to mount. Default value is nil.
Returns
boolean success
rename

Renames a file or folder.


function rename ( string oldPath, string newPath )

Parameters
stringoldPath
stringnewPath
Returns
boolean success
saveFile

Create or overwrite a file to contain the contents of a given string.


function saveFile ( string filename [, string contents ] )

Parameters
stringfilename
stringcontents Optional.
Returns
nil
setWorkingDirectory

Sets the current working directory.


function setWorkingDirectory ( string path )

Parameters
stringpath
Returns
boolean success
stripPKZipTimestamps

Strip the timestamp from a pkzip file. Useful in systems where periodically generated pkzip files are compared against each other using hashes. Once timestamps are stripeed, two pkzip files with the same contents should produce identical hashes.


function stripPKZipTimestamps ( string infilename, string outfilename )

Parameters
stringinfilename
stringoutfilename
Returns
boolean success