FileSystemManager.access
Introduction
Checks if a file/directory exists.
Usage Restrictions
Supported on basic library version 3.0.0 or higher.
Parameters
Object object
| Property | Type | Default Value | Required | Description | 
|---|---|---|---|---|
| path | string | Yes | The file/directory path to check (relative path) | |
| success | function | No | Callback function executed when the interface call is successful | |
| fail | function | No | Callback function executed when the interface call fails | |
| complete | function | No | Callback function executed when the interface call ends (executed regardless of success or failure) | 
object.success Callback Function
Parameters
Object res
| Property | Type | Description | 
|---|---|---|
| success | string | true - Set successfully | 
object.fail
Callback Function
Parameters
Object res
| Property | Type | Description | 
|---|---|---|
| errMsg | string | Error message | 
| success | string | false - Set failed | 
errMsg Description
| Error Message | Description | 
|---|---|
| parameter error: F10001 | Invalid parameter | 
| fail sdcard not mounted: F10002 | Android sdcard mount failed | 
| fail no such file or directory: F10007, ${path} | File/directory does not exist | 
| fail operation not permitted, unlink ${filePath} | The filePath provided is a directory | 
Sample Code
// pages/index/index.js
Page({
  access() {
    const fs = dlt.getFileSystemManager();
    fs.access({
      path: `${dlt.env.USER_DATA_PATH}/hello.txt`,
      success(res) {
        // File exists
        console.log(res);
      },
      fail(res) {
        // File does not exist or other errors
        console.error(res);
      },
    });
  },
});