24 #include <sys/types.h>
39 return (
file->current -
file->start);
65 file->current =
file->start + offset;
68 file->current += offset;
110 return (fflush(
file->file));
135 if (
file->current + tot >
file->end) {
137 cnt = (int)tot / size;
139 memcpy(ptr,
file->current, tot);
140 file->current += tot;
143 return (fread(ptr, size, nmemb,
file->file));
156 size_t dig_fwrite(
const void *ptr,
size_t size,
size_t nmemb,
160 G_fatal_error(
_(
"Writing to file loaded to memory not supported"));
163 return fwrite(ptr, size, nmemb,
file->file);
195 G_debug(2,
"dig_file_load ()");
198 G_warning(
_(
"Unable to load file to memory, file not open"));
213 G_warning(
_(
"Vector memory mode not supported, using 'AUTO'"));
215 G_debug(2,
" requested mode = %d", mode);
217 fstat(fileno(
file->file), &sbuf);
220 G_debug(2,
" size = %lu", (
long unsigned int)size);
238 ret = fread(
file->start, size, 1,
253 G_debug(2,
" file was loaded to the memory");
257 G_debug(2,
" file was not loaded to the memory");
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
off_t G_ftell(FILE *)
Get the current file position of the stream.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
int G_debug(int, const char *,...) __attribute__((format(printf
const char * G_getenv_nofatal(const char *)
Get environment variable.
#define GV_MEMORY_ALWAYS
Memory mode.
int dig_file_load(struct gvfile *file)
Load opened struct gvfile to memory.
size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, struct gvfile *file)
Write struct gvfile.
size_t dig_fread(void *ptr, size_t size, size_t nmemb, struct gvfile *file)
Read struct gvfile.
off_t dig_ftell(struct gvfile *file)
Get struct gvfile position.
void dig_rewind(struct gvfile *file)
Rewind file position.
int dig_fseek(struct gvfile *file, off_t offset, int whence)
Set struct gvfile position.
int dig_fflush(struct gvfile *file)
Flush struct gvfile.
void dig_file_init(struct gvfile *file)
Initialize gvfile structure.
void dig_file_free(struct gvfile *file)
Free struct gvfile.