grits-data

grits-data — Miscellaneous utilities for data access

Synopsis

#include <glib/gstdio.h>

enum                GritsCacheType;
void                (*GritsChunkCallback)               (gchar *file,
                                                         goffset cur,
                                                         goffset total,
                                                         gpointer user_data);
FILE *              fopen_p                             (const gchar *path,
                                                         const gchar *mode);

Description

Various support routines for data access, these are mostly related to disk caching.

Details

enum GritsCacheType

typedef enum {
	GRITS_LOCAL,
	GRITS_ONCE,
	GRITS_UPDATE,
	GRITS_REFRESH,
} GritsCacheType;

Various methods for caching data

GRITS_LOCAL

Only return local files (for offline mode)

GRITS_ONCE

Download the file only if it does not exist

GRITS_UPDATE

Update the file to be like the server

GRITS_REFRESH

Delete the existing file and fetch a new copy

GritsChunkCallback ()

void                (*GritsChunkCallback)               (gchar *file,
                                                         goffset cur,
                                                         goffset total,
                                                         gpointer user_data);

Function called when part of a file is fetched Used for updating progress bars, etc

file :

path to the file which is being fetched

cur :

current offset in the file

total :

total size of the file

user_data :

the user_data argument passed to the function

fopen_p ()

FILE *              fopen_p                             (const gchar *path,
                                                         const gchar *mode);

Open a file, creating parent directories if needed

path :

the path to the file to be opened.

mode :

mode to open the file, see fopen for details

Returns :

the opened file descriptor