@js-soft/native-abstractions / Exports / INativeFileAccess
Access the native filesystem (read/write)
- createDirectory
- deleteDirectory
- deleteFile
- existsDirectory
- existsFile
- infoDirectory
- infoFile
- init
- openFile
- openFileContent
- readFileAsBinary
- readFileAsText
- select
- writeFile
▸ createDirectory(path
, storage?
): Promise
<Result
<void
, ApplicationError
>>
Create a directory
Name | Type | Description |
---|---|---|
path |
string |
path of the directory relative to the storage |
storage? |
NativeFileStorage |
storage location of the directory |
Promise
<Result
<void
, ApplicationError
>>
▸ deleteDirectory(path
, storage?
): Promise
<Result
<void
, ApplicationError
>>
Delete a directory
Name | Type | Description |
---|---|---|
path |
string |
path of the directory relative to the storage |
storage? |
NativeFileStorage |
storage location of the directory |
Promise
<Result
<void
, ApplicationError
>>
▸ deleteFile(path
, storage?
): Promise
<Result
<void
, ApplicationError
>>
Delete specified file
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<void
, ApplicationError
>>
▸ existsDirectory(path
, storage?
): Promise
<Result
<boolean
, ApplicationError
>>
Test if a directory exists
Name | Type | Description |
---|---|---|
path |
string |
path of the directory relative to the storage |
storage? |
NativeFileStorage |
storage location of the directory |
Promise
<Result
<boolean
, ApplicationError
>>
▸ existsFile(path
, storage?
): Promise
<Result
<boolean
, ApplicationError
>>
Test if a file exists
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<boolean
, ApplicationError
>>
▸ infoDirectory(path
, storage?
): Promise
<Result
<INativeDirectory
, ApplicationError
>>
Retrieve information about a specified directory
Name | Type | Description |
---|---|---|
path |
string |
path of the directory relative to the storage |
storage? |
NativeFileStorage |
storage location of the directory |
Promise
<Result
<INativeDirectory
, ApplicationError
>>
▸ infoFile(path
, storage?
): Promise
<Result
<INativeFileMetadata
, ApplicationError
>>
Retrieve meta information about the specified file
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<INativeFileMetadata
, ApplicationError
>>
▸ init(): Promise
<Result
<void
, ApplicationError
>>
Initialize the native features and create a folder structure
Promise
<Result
<void
, ApplicationError
>>
▸ openFile(path
, storage?
): Promise
<Result
<void
, ApplicationError
>>
Open a file with the standard application specified by the operating system
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<void
, ApplicationError
>>
▸ openFileContent(content
, metadata
): Promise
<Result
<void
, ApplicationError
>>
Create and open a file with the standard application specified by the operating system
Name | Type | Description |
---|---|---|
content |
Uint8Array |
content of the file |
metadata |
INativeFileMetadata |
metadata of the file |
Promise
<Result
<void
, ApplicationError
>>
▸ readFileAsBinary(path
, storage?
): Promise
<Result
<Uint8Array
, ApplicationError
>>
Read the data of the specified file as a an array
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<Uint8Array
, ApplicationError
>>
▸ readFileAsText(path
, storage?
): Promise
<Result
<string
, ApplicationError
>>
Read the data of the specified file as a string
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
storage? |
NativeFileStorage |
storage location of the file |
Promise
<Result
<string
, ApplicationError
>>
▸ select(): Promise
<Result
<INativeFile
, ApplicationError
>>
Open the file selection dialog of the operating system and receive the selected file
Promise
<Result
<INativeFile
, ApplicationError
>>
▸ writeFile(path
, data
, storage?
, append?
): Promise
<Result
<void
, ApplicationError
>>
Write data to a file
Name | Type | Description |
---|---|---|
path |
string |
path to the file relative to the storage |
data |
string | Uint8Array |
data to write to the file |
storage? |
NativeFileStorage |
storage location of the file |
append? |
boolean |
overwrite file or append data on the end of the file |
Promise
<Result
<void
, ApplicationError
>>