summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/file.c52
-rw-r--r--navit/file.h15
2 files changed, 33 insertions, 34 deletions
diff --git a/navit/file.c b/navit/file.c
index ffe79f7d8..a17ed4ce1 100644
--- a/navit/file.c
+++ b/navit/file.c
@@ -43,8 +43,6 @@
#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;
@@ -73,8 +71,6 @@ file_create(char *name)
file->size=stat.st_size;
file->name = g_strdup(name);
dbg_assert(file != NULL);
- file->next=file_list;
- file_list=file;
return file;
}
@@ -250,18 +246,6 @@ file_remap_readonly(struct file *f)
}
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__)
@@ -271,20 +255,6 @@ file_unmap(struct file *f)
#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)
{
@@ -405,6 +375,28 @@ file_get_param(struct file *file, struct param_list *param, int count)
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)
{
diff --git a/navit/file.h b/navit/file.h
index 971e32d9c..bf05b6cca 100644
--- a/navit/file.h
+++ b/navit/file.h
@@ -20,6 +20,9 @@
#ifndef NAVIT_FILE_H
#define NAVIT_FILE_H
+#ifndef __CEGCC__
+#include <time.h>
+#endif
#include "param.h"
struct file {
@@ -29,9 +32,14 @@ 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;
};
@@ -49,9 +57,7 @@ unsigned char *file_data_read_compressed(struct file *file, long long offset, in
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);
@@ -62,6 +68,7 @@ int file_wordexp_get_count(struct file_wordexp *wexp);
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