Namespace hcap.file
hcap.file
- Defined in: hcap-1.24.6.5901.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
Method Summary
Namespace Detail
hcap.file
Method Detail
-
<static> hcap.file.deleteUsbFile(param)Deletes the file or directory given by the path in the USB storage.
hcap.file.deleteUsbFile({ "path" : "/tmp/usb/sda/sda1/download/a.mp4", // or a directory "/tmp/usb/sda/sda1/download" "onSuccess" : function() { console.log("onSuccess"); }, "onFailure" : function(f) { console.log("onFailure : errorMessage = " + f.errorMessage); } });- Parameters:
- {Object} param
- {String} param.path [Required] - file path or directory path to delete in the USB storage. Only the file path or the directory path under a USB mount point path (except the root directory of a USB mount point path as a directory path) are allowed. The designated path will be deleted without any warning. (It is same as "rm -rf") And if the path doesn't exist, the success callback will be returned.
- {Function} param.onSuccess [Optional] - success callback function.
param.onSuccess = function (param) { // No Parameter. } - {Function} param.onFailure [Optional] - failure callback function.
param.onFailure = function (param) { // {String} param.errorMessage - in case of failure, this message provides the details. }
-
<static> hcap.file.downloadFileToUsb(param)Downloads the file given by uri to the path in the USB storage.
The result for the download can be obtained by registering the {Event} usb_file_downloaded
hcap.file.downloadFileToUsb({ "uri" : "http://mycompany.com/resource/a.mp3", "path" : "/tmp/usb/sda/sda1/download/b.mp3", "onSuccess" : function() { console.log("onSuccess"); }, "onFailure" : function(f) { console.log("onFailure : errorMessage = " + f.errorMessage); } });- Parameters:
- {Object} param
- {String} param.uri [Required] - URI for the file to download to the USB storage. Only "http" and "https" are allowed.
- {String} param.path [Required] - file path to download the file of uri. The file path should be equal to or lower than a USB mount point path. And if the directory doesn't exist, it will be created automatically.
- {Function} param.onSuccess [Optional] - success callback function.
param.onSuccess = function (param) { // No Parameter. } - {Function} param.onFailure [Optional] - failure callback function.
param.onFailure = function (param) { // {String} param.errorMessage - in case of failure, this message provides the details. }
-
<static> hcap.file.getUsbStorageFileList(param)Gets the file list for the given path in a USB storage.
hcap.file.getUsbStorageList({ "onSuccess" : function(s) { hcap.file.getUsbStorageFileList({ "path" : s[0].mountPoint, "onSuccess" : function (param) { console.log("file list length = " + param.list.length); for (var i = 0; i < param.list.length; i++) { console.log( "[" + i + "].name = " + param.list[i].name + "[" + i + "].type = " + param.list[i].type + "[" + i + "].length = " + param.list[i].length ); } }, "onFailure" : function(ff) { console.log("onFailure : errorMessage = " + ff.errorMessage); } }); }, "onFailure" : function(f) { console.log("onFailure : errorMessage = " + f.errorMessage); } });- Parameters:
- {Object} param
- {String} param.path [Required] - directory path to get file list. Only the directory equal to or lower than a USB mount point path is allowed.
- {Number} param.position [Optional] - start position (starts with 0) where starts to make file list in the directory. Default position is 0.
- {Number} param.length [Optional] - at most the length number of files from the position will be listed up. Default length is 100.
- {Function} param.onSuccess [Optional] - success callback function.
param.onSuccess = function (param) { // {Array} param.list - file list // {String} param.list[].name - file name // {String} param.list[].type - file type among "BLK"(block device), "CHR"(character device), "DIR"(directory), "FIFO"(named pipe), "LNK"(symbolic link), "REG"(regular file), "SOCK"(UNIX domain socket) and "UNKNOWN"(unknown) // {String} param.list[].length - file length } - {Function} param.onFailure [Optional] - failure callback function.
param.onFailure = function (param) { // {String} param.errorMessage - in case of failure, this message provides the details. }
-
<static> hcap.file.getUsbStorageList(param)Gets the USB storage list.
hcap.file.getUsbStorageList({ "onSuccess" : function(s) { console.log("onSuccess : list length = " + s.list.length); for (var i = 0; i < s.list.length; i++) { console.log( "[" + i + "].name = " + s.list[i].name + "[" + i + "].displayName = " + s.list[i].displayName + "[" + i + "].mountPoint = " + s.list[i].mountPoint + "[" + i + "].status = " + s.list[i].status + "[" + i + "].filesystemStatus = " + s.list[i].filesystemStatus + "[" + i + "].totalSize = " + s.list[i].totalSize + "[" + i + "].freeSize = " + s.list[i].freeSize ); } }, "onFailure" : function(f) { console.log("onFailure : errorMessage = " + f.errorMessage); } });- Parameters:
- {Object} param
- {Function} param.onSuccess [Optional] - success callback function.
param.onSuccess = function (param) { // {Array} param.list - list for the USB storage devices connected to TV. // {String} param.list[].name - unique device name within the system // {String} param.list[].displayName - display name // {String} param.list[].mountPoint - mount point path // {String} param.list[].status - status among "INIT"(device is initializing), "AVAILABLE"(device is available), "BUSY"(device is unavailable for a while because device is busy in the other work) and "OFFLINE"(device is physically connected but is unavailable) // {String} param.list[].filesystemStatus - filesystem status among "READ_ONLY" and "READ_WRITE" // {String} param.list[].totalSize - total size in bytes // {String} param.list[].freeSize - free size in bytes } - {Function} param.onFailure [Optional] - failure callback function.
param.onFailure = function (param) { // {String} param.errorMessage - in case of failure, this message provides the details. }
- {Function} param.onSuccess [Optional] - success callback function.