diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-10-20 19:21:09 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-10-20 19:21:09 +0000 |
commit | 6ed67adccf9fe32ad3ceb4037f0d529700a53443 (patch) | |
tree | 09681f3265a030a9c0301d0a2a2bbe0f0d7b1701 /navit/file.c | |
parent | e32049ec89cd3b9d01edf92210abcc63c8c90826 (diff) | |
download | navit-6ed67adccf9fe32ad3ceb4037f0d529700a53443.tar.gz |
Add:Core:Added support for checking a files version
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1520 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/file.c')
-rw-r--r-- | navit/file.c | 52 |
1 files changed, 22 insertions, 30 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) { |