This interface is implemented by a File Object.
interface IFile {
// Properties
${currentPosition}: number;
readonly ${size}: number;
readonly ${isOpen}: boolean;
// Methods
${read}(size: number, position?: number): Promise<Uint8Array>;
${write}(data: number[] | Uint8Array | DataView | ArrayBuffer, position?: number): Promise<number>;
${setEnd}(): void;
${close}(): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment
currentPosition: number;
// This property is not available in managed environment
// This property is not available in native environment
This property represents the current file's position.
readonly size: number;
// This property is not available in managed environment
// This property is not available in native environment
This property holds the current file's size.
readonly isOpen: boolean;
// This property is not available in managed environment
// This property is not available in native environment
This property evaluates to false
after calling the IFile.close method.
@returns false
after calling IFile.close method, true
otherwise.
read(size: number, position?: number): Promise<Uint8Array>;
// This method is not available in managed environment
// This method is not available in native environment
size
position
Data read from a file.
Reads data from a file. This method executes asynchronously.
Reading from a file
var data = await file.read(4096);
write(data: number[] | Uint8Array | DataView | ArrayBuffer, position?: number): Promise<number>;
// This method is not available in managed environment
// This method is not available in native environment
data
position
The number of bytes written.
Writes data to a file. This method executes asynchronously.
Writing to a file
// Copy first 4KB of file to second 4KB
var data = await file.read(4096, 0);
await file.write(data, 4096);
setEnd(): void;
// This method is not available in managed environment
// This method is not available in native environment
Changes the size of a file to be the same as IFile.currentPosition.
close(): void;
// This method is not available in managed environment
// This method is not available in native environment
Closes the file. File object may not be used after calling this method. Only IFile.isOpen property may safely be used after calling this method.