Fix:Core:Better win32 module loading
[navit-package] / navit / file.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef NAVIT_FILE_H
21 #define NAVIT_FILE_H
22
23 #ifndef PATH_MAX
24 #define PATH_MAX 4096
25 #endif
26 #ifndef __CEGCC__
27 #include <time.h>
28 #endif
29 #include "param.h"
30 #include <stdio.h>
31
32 struct file {
33         struct file *next;
34         unsigned char *begin;
35         unsigned char *end;
36         unsigned char *mmap_end;
37         long long size;
38         int name_id;
39         int fd;
40 #ifndef __CEGCC__
41         time_t mtime;
42         time_t ctime;
43         int version;                    
44 #endif
45 #if defined(_WIN32) || defined(__CEGCC__)
46         long map_handle;
47         long map_file;
48 #endif
49         char *name;
50         FILE *stdfile;
51         int special;
52         int cache;
53 };
54
55 enum file_flags {
56         file_flag_nocache=1,
57 };
58
59 /* prototypes */
60 struct file *file_create(char *name, enum file_flags flags);
61 int file_is_dir(char *name);
62 long long file_size(struct file *file);
63 int file_mkdir(char *name, int pflag);
64 int file_mmap(struct file *file);
65 unsigned char *file_data_read(struct file *file, long long offset, int size);
66 unsigned char *file_data_read_special(struct file *file, int size, int *size_ret);
67 unsigned char *file_data_read_all(struct file *file);
68 int file_data_write(struct file *file, long long offset, int size, unsigned char *data);
69 int file_get_contents(char *name, unsigned char **buffer, int *size);
70 unsigned char *file_data_read_compressed(struct file *file, long long offset, int size, int size_uncomp);
71 void file_data_free(struct file *file, unsigned char *data);
72 int file_exists(char *name);
73 void file_remap_readonly(struct file *f);
74 void file_unmap(struct file *f);
75 void *file_opendir(char *dir);
76 char *file_readdir(void *hnd);
77 void file_closedir(void *hnd);
78 struct file *file_create_caseinsensitive(char *name, enum file_flags flags);
79 void file_destroy(struct file *f);
80 struct file_wordexp *file_wordexp_new(const char *pattern);
81 int file_wordexp_get_count(struct file_wordexp *wexp);
82 char **file_wordexp_get_array(struct file_wordexp *wexp);
83 void file_wordexp_destroy(struct file_wordexp *wexp);
84 int file_get_param(struct file *file, struct param_list *param, int count);
85 int file_version(struct file *file, int byname);
86 void *file_get_os_handle(struct file *file);
87 void file_init(void);
88 /* end of prototypes */
89
90 #endif
91