/* Filename are relative to the search path * a null buffer will just return the file length without loading */ int FS_loadfile( char *path, void **buffer ) { FILE *h; byte *buf; int len; buf = NULL; /* look for it in the filesystem or pack files */ len = FS_fopenfile(path, &h); if ( !h ) { if (buffer) *buffer = NULL; return -1; } if (!buffer) { fclose (h); return len; } buf = (byte *) ALLOC(len); *buffer = buf; FS_read(buf, len, h); fclose(h); return len; }
ssize_t OW_lread(const char *path, char *buffer, const size_t size, const off_t offset) { ssize_t ret = -EACCES; /* current buffer string length */ /* Check the parameters */ if (buffer == NULL || path == NULL) { return ReturnAndErrno(-EINVAL); } if (API_access_start() == 0) { ret = FS_read(path, buffer, size, offset); API_access_end(); } return ReturnAndErrno(ret); }