FileManager

This class allows you to perform file system operations.  There is only one global instance of this class.

example

Plugins.load( "FileManager");
log( FileManager.currentDirectory );
Summary
This class allows you to perform file system operations.
Lets you set and get the current directory.
Test to see if a file exists.
Test to see if a directory exists.
Deletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.
Returns the contents of a directory.
Creates a directory.
Returns attributes of a file or directory.
Moves a file or directory to another location.

Properties

currentDirectory

string currentDirectory

Lets you set and get the current directory.

Functions

fileExists

bool fileExists(string path)

Test to see if a file exists.

parameters

pathPath to a file.

returns

trueIf the file exists.
falseOtherwise.

directoryExists

bool directoryExists(string path)

Test to see if a directory exists.

parameters

pathPath to a directory.

returns

trueIf the directory exists.
falseOtherwise.

remove

bool remove(string path)

Deletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.  BE CAREFUL!

parameters

pathPath to a file or directory to remove.

returns

trueIf it was removed successfully.
falseOtherwise.

directoryContents

jsval directoryContents(string path ,
bool includeHidden)

Returns the contents of a directory.

parameters

pathThe directory to scan.
includeHiddenIf true, will return normally hidden files, such as those that begin with a dot.

returns

An array of objects like this:

[{"path":"MediaCache","size":102,"type":"d","perm":448},...]

createDirectory

bool createDirectory(string path)

Creates a directory.

parameters

pathThe directory to create.

returns

trueIf it worked.
falseOtherwise.

getAttributes

jsval getAttributes(string path)

Returns attributes of a file or directory.

parameters

pathThe path to the file or directory.

returns

nullIf the file or directory does not exist, or An object describing all the attributes of the file or directory like this:
{ size:102 , type : "f" , perm : 448 , modified : 1197536262000 }

move

bool move(string source ,
string destination)

Moves a file or directory to another location.  Note that this uses the “mv” command line tool.  If it is not present on the phone as /bin/mv this method will fail.

parameters

sourceThe path to the source file or directory.
destinationThe path to the new file or directory.

returns

trueIf it is OK.
falseIf it failed.
string currentDirectory
Lets you set and get the current directory.
bool fileExists(string path)
Test to see if a file exists.
bool directoryExists(string path)
Test to see if a directory exists.
bool remove(string path)
Deletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.
jsval directoryContents(string path ,
bool includeHidden)
Returns the contents of a directory.
bool createDirectory(string path)
Creates a directory.
jsval getAttributes(string path)
Returns attributes of a file or directory.
bool move(string source ,
string destination)
Moves a file or directory to another location.