Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static openForWrite(path: string, dirfd: Descriptor = 3): Descriptor {
let fd_lookup_flags = lookupflags.SYMLINK_FOLLOW;
let fd_oflags: oflags = oflags.CREAT;
let fd_rights =
rights.FD_WRITE |
rights.FD_SEEK |
rights.FD_TELL |
rights.FD_FILESTAT_GET |
rights.PATH_CREATE_FILE;
let fd_rights_inherited = fd_rights;
let fd_flags: fdflags = 0;
let path_utf8_len: usize = path.lengthUTF8 - 1;
let path_utf8 = path.toUTF8();
let fd_buf = changetype(new ArrayBuffer(sizeof()));
let res = path_open(
dirfd as fd,
fd_lookup_flags,
path_utf8,
path_utf8_len,
fd_oflags,
fd_rights,
fd_rights_inherited,
fd_flags,
fd_buf
);
if (res != errno.SUCCESS) {
return InvalidDescriptor;
}
let fd = load(fd_buf);
return fd as Descriptor;
static openForRead(path: string, dirfd: Descriptor = 3): Descriptor {
let fd_lookup_flags = lookupflags.SYMLINK_FOLLOW;
let fd_oflags: oflags = 0;
let fd_rights =
rights.FD_READ | rights.FD_SEEK | rights.FD_TELL | rights.FD_FILESTAT_GET;
let fd_rights_inherited = fd_rights;
let fd_flags: fdflags = 0;
let path_utf8_len: usize = path.lengthUTF8 - 1;
let path_utf8 = path.toUTF8();
let fd_buf = changetype(new ArrayBuffer(sizeof()));
let res = path_open(
dirfd as fd,
fd_lookup_flags,
path_utf8,
path_utf8_len,
fd_oflags,
fd_rights,
fd_rights_inherited,
fd_flags,
fd_buf
);
if (res != errno.SUCCESS) {
return InvalidDescriptor;
}
let fd = load(fd_buf);
return fd as Descriptor;