var fileSystemObj = new FileSystem(); var usbPath = '$USB_DIR' + usb_mount_path; var arrFiles = fileSystemObj.readDir(usbPath) if (arrFiles) {
Example
for (var i=0; i < arrFiles.length; i++) { alert(arrFiles[i].name); alert(arrFiles[i].isDir); } }
Purpose
The readDir( ) interface reads file listing from a USB folder openFile
Usage
fileSystemObj.openFile(filePath, mode); filePath: String
Parameters
File path including the filename mode: String r : open a file to read. The file must already exist. Only the r mode is valid. A browser file system’s instance is returned.
Return Value
The object’s readLine( ) and readAll( ) methods are used to read text from the file. var fileSystemObj = new FileSystem();
Example
var fileObj = fileSystemObj.openFile('$WIDGET' + '/testFile.data', 'r'), var data = fileObj.readAll();
Purpose
The openFile( ) interface opens a file in the application
Table 13 -15. Major File API Functions
File API Example Let’s create an example to demonstrate the File API.
13. Advanced Features
239