Checks if the specified file exists in the file system.
$m.fileExists("offline_orders.txt", function(response) { var message; if(response.code == -1) { // External storage is not ready. Possible reason could be the storage // is mounted to file system on a computer. return; } if(response.result){ message = "File exists." }else { message = "File does not exist."; } $m.toast(message); }); |
Syntax
$m.fileExists(filePath[, fp_callback])
$m.fileExists(file[, fp_callback])
Parameters
filePath
string (required)
The path of the file relative to the pack folder.
file
file (required)
The mowbly file object. Use $m.createFile method to create the mowbly file object. The advantage of using file over filePath parameter is that file object provides options to specify the path relative to the application folder or storage root apart from pack.
fp_callback
function (optional)
Function to execute when the file exists check is done. The function receives a response object as parameter with the following properties,
- code - {Number}. Possible codes are,
- -1 - Storage is not ready.
- 1 - File path is successfully read.
- 0 - Error in reading file path.
- result - {Boolean}. True, if the delete file operation is successful; false, otherwise.
- error - {Object}. Available when the code is 0. The error object contains,
- message - {String}. A short description of the error.
- description - {String}. A detailed description of the error.