Skip to main content
Version: v3

hmFS.open(path, flag)

Open file

Type

(path: string, flag: FLAG) => fileId

Parameters

path

DescriptionRequiredTypeDefault
file pathyesstring-

FLAG

Optional PropertiesDescription
O_RDONLYread-only
O_WRONLYwrite-only
O_RDWRread-write
O_APPENDAppend mode on.
O_CREATIf file does not exist, create and open.
O_EXCLUsed in conjunction with O_CREAT. If it does not exist, create and open it, if it does exist, return an error.
O_TRUNCIf the file exists, the length is truncated to 0.

fileId

DescriptionType
file handlenumber

Usage

const fileId = hmFS.open('test_file.txt', hmFS.O_RDWR | hmFS.O_CREAT)