top

readDir

Published 2014-10-28 | (Compatible with SDK 2.5,3.5,4.5,5.0,5.1 and 2010,2011,2012,2013,2014 models)

Enables viewing file information in USB.

The readDir class enables viewing file information in USB.

readDir
Syntax fileSystemObj.readDir(directoryPath)
Parameter
directoryPath (String)
Path of a directory that you want to see. Works only for USB directory
Return Value
(Array)
The Array containing file information. Each element has file information in a directory. Able to get information by referring to variables below.
  • name : file name
  • isDir : If a file is a directory true, if not false
  • size : File Size (byte)
  • atime : The time when to open a file or access time to a directory with cd command
  • mtime : The time when file contents are changed
  • ctime : The time when file information is changed. If there is no directoryPath, return false.
Remarks File information in USB can be brought by $USB_DIR. For the way to find out mounted path of USB, refer to storage plugin of Plugin guide.
Example
var fileSystemObj = new FileSystem();
var usbPath = '$USB_DIR' + usb_mount_path;
var arrFiles = fileSystemObj.readDir(usbPath)
if (arrFiles) {
    for (var i=0; i < arrFiles.length; i++) {
        alert(arrFiles[i].name);
        alert(arrFiles[i].isDir);
    }
}
Enumeration None