#define O_BINARY 0
#endif
-static struct file *file_list;
-
static GHashTable *file_name_hash;
static int file_name_id;
static struct cache *file_cache;
file->size=stat.st_size;
file->name = g_strdup(name);
dbg_assert(file != NULL);
- file->next=file_list;
- file_list=file;
return file;
}
}
void
-file_remap_readonly_all(void)
-{
- struct file *f=file_list;
- int limit=1000;
-
- while (f && limit-- > 0) {
- file_remap_readonly(f);
- f=f->next;
- }
-}
-
-void
file_unmap(struct file *f)
{
#if defined(_WIN32) || defined(__CEGCC__)
#endif
}
-void
-file_unmap_all(void)
-{
- struct file *f=file_list;
- int limit=1000;
-
- while (f && limit-- > 0) {
- file_unmap(f);
- f=f->next;
- }
-}
-
-
-
void *
file_opendir(char *dir)
{
return i-count;
}
+int
+file_version(struct file *file, int byname)
+{
+#ifndef __CEGCC__
+ struct stat st;
+ int error;
+ if (byname)
+ error=stat(file->name, &st);
+ else
+ error=fstat(file->fd, &st);
+ if (error || !file->version || file->mtime != st.st_mtime || file->ctime != st.st_ctime) {
+ file->mtime=st.st_mtime;
+ file->ctime=st.st_ctime;
+ file->version++;
+ dbg(0,"%s now version %d\n", file->name, file->version);
+ }
+ return file->version;
+#else
+ return 0;
+#endif
+}
+
void
file_init(void)
{
#ifndef NAVIT_FILE_H
#define NAVIT_FILE_H
+#ifndef __CEGCC__
+#include <time.h>
+#endif
#include "param.h"
struct file {
char *name;
int name_id;
int fd;
+#ifndef __CEGCC__
+ time_t mtime;
+ time_t ctime;
+ int version;
+#endif
#if defined(_WIN32) || defined(__CEGCC__)
- long map_handle;
- long map_file;
+ long map_handle;
+ long map_file;
#endif
struct file *next;
};
void file_data_free(struct file *file, unsigned char *data);
int file_exists(char *name);
void file_remap_readonly(struct file *f);
-void file_remap_readonly_all(void);
void file_unmap(struct file *f);
-void file_unmap_all(void);
void *file_opendir(char *dir);
char *file_readdir(void *hnd);
void file_closedir(void *hnd);
char **file_wordexp_get_array(struct file_wordexp *wexp);
void file_wordexp_destroy(struct file_wordexp *wexp);
int file_get_param(struct file *file, struct param_list *param, int count);
+int file_version(struct file *file, int byname);
/* end of prototypes */
#endif