File fhFileUtils.lua

Functions

copyFile (sPath, sDestination) Copies an existing file and returns true if file copied OK
copyFolder (sPath, sDestination) Copies an existing folder and returns true if folder copied OK
createFolder (sPath) Creates a folder and returns true if folder created
createTextFile (sPath, bOverwrite, bUnicode, sContents) Creates a text file with optional contents and returns true if file created
deleteFile (sPath) Deletes existing file and returns true if file deleted
deleteFolder (sPath) Deletes a folder and all its contents and returns true if folder deleted
fileExists (sPath) Returns true if specified file exists
folderExists (sPath) Returns true if specified folder exists
getFolderContents (sPath, bRecurse) Return table of all files and folders in a specified folder.
getParent (sPath) Returns Parent folder for Path Provided
getShortPath (sPath) Gets the short path for a file or folder, suitabl for use with lua io library
moveFile (sPath, sDestination) Moves an existing file and returns true if file moved OK
moveFolder (sPath, sDestination) Moves an existing folder and returns true if moved OK
readTextFile (sPath, bUnicode) Reads an existing text file and returns a string of the contents
renameFile (sPath, sNewName) Renames an existing file in its current location and returns true if file renamed
renameFolder (sPath, sNewName) Renames an existing folder in its current location and returns true if folder renamed
splitPath (sPath) Returns table of Path Parts drive=drive letter with colon, abs_path=fully resolved path, parent = parent folder,filename= file name excluding path,basename=file name excluding path and extension,ext=extension Notes: path is not validated only split; network file paths are not supported.


Functions

copyFile (sPath, sDestination)
Copies an existing file and returns true if file copied OK

Parameters:

  • sPath: Full File Path
  • sDestination: Full File Path

Return value:

    True if file copied
copyFolder (sPath, sDestination)
Copies an existing folder and returns true if folder copied OK

Parameters:

  • sPath: Full Folder Path
  • sDestination: Full Folder Path

Return value:

    True if folder copied
createFolder (sPath)
Creates a folder and returns true if folder created

Parameters:

  • sPath: Full Folder Path

Return value:

    True if folder created
createTextFile (sPath, bOverwrite, bUnicode, sContents)
Creates a text file with optional contents and returns true if file created

Parameters:

  • sPath: Full File Path
  • bOverwrite: True if existing file can be overwritten. Defaults to true
  • bUnicode: True if file should be a Unicode file. Defaults to false (ASCII file)
  • sContents: Optional contents to be written to file

Return value:

    boolean True if file created
deleteFile (sPath)
Deletes existing file and returns true if file deleted

Parameters:

  • sPath: Full File Path

Return value:

    True if file deleted
deleteFolder (sPath)
Deletes a folder and all its contents and returns true if folder deleted

Parameters:

  • sPath: Full Folder Path

Return value:

    True if folder deleted
fileExists (sPath)
Returns true if specified file exists

Parameters:

  • sPath: Full File Path

Return value:

    True if file exists
folderExists (sPath)
Returns true if specified folder exists

Parameters:

  • sPath: Full Folder Path

Return value:

    True if folder exists
getFolderContents (sPath, bRecurse)
Return table of all files and folders in a specified folder. For each item the type,path,shortname, shortpath, created date,modified date,size and attributes are returned in a table.

Parameters:

  • sPath: Full Folder Path
  • bRecurse: boolean Recurse subfolders

Return value:

    Table of Results or False if specified folder not found
getParent (sPath)
Returns Parent folder for Path Provided

Parameters:

  • sPath: Full File or Folder Path

Return value:

    Path of Parent Folder or False if path not found
getShortPath (sPath)
Gets the short path for a file or folder, suitabl for use with lua io library

Parameters:

  • sPath: Full File or Folder Path

Return value:

    Short Path string or False if the path doesn't exist
moveFile (sPath, sDestination)
Moves an existing file and returns true if file moved OK

Parameters:

  • sPath: Full File Path
  • sDestination: Full File Path

Return value:

    True if file moved
moveFolder (sPath, sDestination)
Moves an existing folder and returns true if moved OK

Parameters:

  • sPath: Full Folder Path
  • sDestination: Full Folder Path

Return value:

    True if folder moved
readTextFile (sPath, bUnicode)
Reads an existing text file and returns a string of the contents

Parameters:

  • sPath: Full File Path
  • bUnicode: True if file is a Unicode file. Defaults to false (ASCII file)

Return value:

    string Contents of the file or False if the file doesn't exist
renameFile (sPath, sNewName)
Renames an existing file in its current location and returns true if file renamed

Parameters:

  • sPath: Full File Path
  • sNewName: New File Name including Extension

Return value:

    True if file renamed
renameFolder (sPath, sNewName)
Renames an existing folder in its current location and returns true if folder renamed

Parameters:

  • sPath: Full Folder Path
  • sNewName: New Folder Name

Return value:

    True if folder renamed
splitPath (sPath)
Returns table of Path Parts drive=drive letter with colon, abs_path=fully resolved path, parent = parent folder,filename= file name excluding path,basename=file name excluding path and extension,ext=extension Notes: path is not validated only split; network file paths are not supported.

Parameters:

  • sPath: Full File or Folder Path (excludng network file paths)

Valid XHTML 1.0!