Example #1
0
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;
}
Example #2
0
int close(int fd)
{
	if (fd & SOCKET_FD_MASK)
		return net_close(fd);

	return lv2Errno(lv2FsClose(fd));
}
Example #3
0
int close(int fd)
{
	if (fd & SOCKET_FD_MASK)
		return closesocket(fd);

	return lv2Errno(lv2FsClose(fd));
}
Example #4
0
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;
}
Example #5
0
int unlink(const char* path)
{
	return lv2Errno(lv2FsUnlink(path));
}
Example #6
0
int ftruncate(int fd, off_t length)
{
	return lv2Errno(lv2FsFtruncate(fd, length));
}
Example #7
0
int truncate(const char* path, off_t length)
{
	return lv2Errno(lv2FsTruncate(path, length));
}
Example #8
0
int fsync(int fd)
{
	return lv2Errno(lv2FsFsync(fd));
}