int open(const char* path, int oflag, ...) { Lv2FsFile fd; int lv2flag = oflag & (O_ACCMODE | LV2_O_MSELF); if (oflag & O_CREAT) lv2flag |= LV2_O_CREAT; if (oflag & O_TRUNC) lv2flag |= LV2_O_TRUNC; if (oflag & O_EXCL) lv2flag |= LV2_O_EXCL; if (oflag & O_APPEND) lv2flag |= LV2_O_APPEND; int mode = 0; if (oflag & O_WRONLY) mode = DEFAULT_FILE_MODE; int ret = lv2FsOpen(path, lv2flag, &fd, mode, NULL, 0); if (ret) return lv2Errno(ret); if (oflag & O_CREAT) lv2FsChmod(path, DEFAULT_FILE_MODE); return fd; }
int close(int fd) { if (fd & SOCKET_FD_MASK) return net_close(fd); return lv2Errno(lv2FsClose(fd)); }
int close(int fd) { if (fd & SOCKET_FD_MASK) return closesocket(fd); return lv2Errno(lv2FsClose(fd)); }
int netInitialize() { if (__netMemory) return 0; s32 ret = SysLoadModule(SYSMODULE_NET); if (ret < 0) return lv2Errno(ret); __netMemory = malloc(LIBNET_MEMORY_SIZE); netInitialization init; memset(&init, 0, sizeof(init)); init.memory = (lv2_void)(u64)__netMemory; init.memory_size = LIBNET_MEMORY_SIZE; init.flags = 0; ret = netInitializeNetworkEx(&init); if (ret) { free(__netMemory); __netMemory = NULL; } return ret; }
int unlink(const char* path) { return lv2Errno(lv2FsUnlink(path)); }
int ftruncate(int fd, off_t length) { return lv2Errno(lv2FsFtruncate(fd, length)); }
int truncate(const char* path, off_t length) { return lv2Errno(lv2FsTruncate(path, length)); }
int fsync(int fd) { return lv2Errno(lv2FsFsync(fd)); }