24 #include <sys/types.h> 110 return (fflush(file->
file));
137 cnt = (int)tot / size;
139 memcpy(ptr, file->
current, tot);
143 return (fread(ptr, size, nmemb, file->
file));
159 G_fatal_error(
_(
"Writing to file loaded to memory not supported"));
162 return fwrite(ptr, size, nmemb, file->
file);
194 G_debug(2,
"dig_file_load ()");
197 G_warning(
_(
"Unable to load file to memory, file not open"));
212 G_warning(
_(
"Vector memory mode not supported, using 'AUTO'"));
214 G_debug(2,
" requested mode = %d", mode);
217 fstat(fileno(file->
file), &sbuf);
220 G_debug(2,
" size = %lu", (
long unsigned int) size);
237 ret = fread(file->
start, size, 1, file->
file);
251 G_debug(2,
" file was loaded to the memory");
255 G_debug(2,
" file was not loaded to the memory");
size_t dig_fread(void *ptr, size_t size, size_t nmemb, struct gvfile *file)
Read struct gvfile.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void dig_file_init(struct gvfile *file)
Initialize gvfile strcuture.
char * current
Current position set by dig_seek()
char * end
End of file in the memory (pointer to first byte after)
void G_free(void *)
Free allocated memory.
off_t alloc
Allocated space.
int dig_file_load(struct gvfile *file)
Load opened struct gvfile to memory.
#define GV_MEMORY_ALWAYS
Memory mode.
void dig_rewind(struct gvfile *file)
Rewind file position.
int loaded
Is file loaded?
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
int dig_fseek(struct gvfile *file, off_t offset, int whence)
Set struct gvfile position.
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
off_t size
Size of the file loaded to memory.
off_t G_ftell(FILE *)
Get the current file position of the stream.
off_t dig_ftell(struct gvfile *file)
Get struct gvfile position.
FILE * file
File descriptor.
int dig_fflush(struct gvfile *file)
Flush struct gvfile.
void dig_file_free(struct gvfile *file)
Free struct gvfile.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_warning(const char *,...) __attribute__((format(printf
char * start
Pointer to beginning of the file in the memory.
const char * G_getenv_nofatal(const char *)
Get environment variable.
size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, struct gvfile *file)
Write struct gvfile.
int G_debug(int, const char *,...) __attribute__((format(printf