bn.getFileSystemManager
▸ getFileSystemManager(): FileSystemManager
description
Get the file system manager instance which is a singleton. On Android devices, file system api will save file on external storage by default.- About filePath: filePath should starts from root directory of source code bundle.Only supports absolute path like /a/b
or a/b
.Files with extensions of js,json,bxss,bxm
will be transformed into other files after compilation, so they are not expected to be accessible.
- Valid value of encoding: utf-8, utf8
example
const manager = bn.getFileSystemManager()
manager.readFile({filePath: 'xxx'})
Returns
FileSystemManager
Class: FileSystemManager
Name | Type | Description |
---|---|---|
rpc | RPC | |
readFileNative | undefined | (options : ReadFileOption ) => Promise <FSReadFileResult > | |
writeFileNative | undefined | (options : WriteFileOption ) => Promise <GeneralCallbackResult > | |
readFileNativeSync | undefined | (options : any ) => any | |
writeFileNativeSync | undefined | (options : any ) => any | |
readFile | (options ): Promise <FSReadFileResult > | description Read files in local directory. |
writeFile | (options ): Promise <GeneralCallbackResult > | description Write data into file in local directory. |
mkdir | (options ): Promise <{}> | description Create directory. |
access | (options ): Promise <{}> | description Try to access file/directory. |
unzip | (options ): Promise <{}> | description Unzip file. |
copyFile | (options ): Promise <{}> | description Copy file to another path. |
readFileSync | (filePath , encoding? , position? , length? ): FileData | description Sync version of readFile. |
writeFileSync | (filePath , data , encoding? ): any | description Sync version of writeFile. |
mkdirSync | (dirPath , recursive? ): Object | description Sync version of mkdir. |
accessSync | (path ): Object | description Sync version of access. |
copyFileSync | (srcPath , destPath ): Object | description Sync version of copyFile. |
readFile
▸ readFile(options
): Promise
<FSReadFileResult
>
description
Read files in local directory.
example
bn.getFileSystemManager().readFile({
filePath: `${bn.env.USER_DATA_PATH}/helloWorld.txt`,
encoding: 'utf-8',
success(res) {
console.log(res)
},
})
Parameters
Name | Type |
---|---|
options | ReadFileOption |
Returns
Promise
<FSReadFileResult
>