size_t URI_file_Read(int Handle, size_t Bytes, void *Buffer);
size_t URI_file_Write(int Handle, size_t Bytes, void *Buffer);
void URI_file_Close(int Handle);
-size_t URI_file_GetSize(int Handle);
+off_t URI_file_GetSize(int Handle);
// === CONSTANTS ===
// Builtin URI protocol handlers
{
int hostlen, portlen, pathlen;
tmp += 3; // Eat '://'
- ret = malloc(sizeof(tURI) + strlen(String) - 2);
+ ret = malloc(sizeof(tURI) + protolen + 1 + strlen(tmp) + 1);
ret->Proto = (char*)ret + sizeof(tURI);
memcpy(ret->Proto, String, protolen);
else
ret->Path = ret->Host + hostlen + 1;
- tmp ++;
pathlen = 0;
- while(*tmp)
- {
- ret->Path[pathlen] = *tmp;
- tmp ++;
- pathlen ++;
- }
+ strcpy(ret->Path, tmp);
return ret;
}
// printf("URI_file_Open: open('%s', 0x%x)\n", Path, smode);
{
int ret;
- ret = open(Path, smode);
+ ret = _SysOpen(Path, smode);
return ret;
}
}
{
// printf("URI_file_Read: (Handle=%i, Buffer=%p, Bytes=%i)\n",
// Handle, Buffer, (int)Bytes);
- return read(Handle, Buffer, Bytes);
+ return _SysRead(Handle, Buffer, Bytes);
}
size_t URI_file_Write(int Handle, size_t Bytes, void *Buffer)
{
- return write(Handle, Buffer, Bytes);
+ return _SysWrite(Handle, Buffer, Bytes);
}
void URI_file_Close(int Handle)
{
- close(Handle);
+ _SysClose(Handle);
}
-size_t URI_file_GetSize(int Handle)
+off_t URI_file_GetSize(int Handle)
{
- uint64_t curpos = tell(Handle);
- size_t ret;
- seek(Handle, 0, SEEK_END);
- ret = tell(Handle);
- seek(Handle, curpos, SEEK_SET);
+ uint64_t curpos = _SysTell(Handle);
+ off_t ret;
+ _SysSeek(Handle, 0, SEEK_END);
+ ret = _SysTell(Handle);
+ _SysSeek(Handle, curpos, SEEK_SET);
return ret;
}