~vkolesnikov/pbxt/pbxt-preload-test-bug

« back to all changes in this revision

Viewing changes to pbxt/src/filesys_xt.h

  • Committer: paul-mccullagh
  • Date: 2008-03-10 11:36:34 UTC
  • Revision ID: paul-mccullagh-417ebf175a9c8ee6e5b3777d9e2398e1fb197391
Implemented full durability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2005 SNAP Innovation GmbH
 
1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
2
2
 *
3
3
 * PrimeBase XT
4
4
 *
33
33
 
34
34
#include "xt_defs.h"
35
35
 
 
36
#ifdef XT_WIN
 
37
#define XT_FILE_NOT_FOUND(x)    ((x) == ERROR_FILE_NOT_FOUND || (x) == ERROR_PATH_NOT_FOUND)
 
38
#else
 
39
#define XT_FILE_NOT_FOUND(x)    ((x) == ENOENT)
 
40
#endif
 
41
 
36
42
struct XTOpenFile;
37
43
 
38
44
#define XT_MASK                         ((S_IRUSR | S_IWUSR) | (S_IRGRP | S_IWGRP) | (S_IROTH))
42
48
#define XT_FS_CREATE            2               /* Create if the file does not exist. */
43
49
#define XT_FS_EXCLUSIVE         4               /* Create, and generate an error if it already exists. */
44
50
#define XT_FS_MISSING_OK        8               /* Set this flag if you don't want to throw an error if the file does not exist! */
 
51
#define XT_FS_MAKE_PATH         16              /* Create the path if it does not exist. */
45
52
 
46
53
xtBool                  xt_fs_exists(char *path);
47
54
xtBool                  xt_fs_delete(struct XTThread *self, char *path);
48
55
xtBool                  xt_fs_file_not_found(int err);
49
56
void                    xt_fs_mkdir(struct XTThread *self, char *path);
50
 
void                    xt_fs_rmdir(struct XTThread *self, char *path);
 
57
void                    xt_fs_mkpath(struct XTThread *self, char *path);
 
58
xtBool                  xt_fs_rmdir(struct XTThread *self, char *path);
51
59
xtBool                  xt_fs_stat(struct XTThread *self, char *path, off_t *size, struct timespec *mod_time);
52
60
void                    xt_fs_move(struct XTThread *self, char *from_path, char *to_path);
53
61
xtBool                  xt_fs_rename(struct XTThread *self, char *from_path, char *to_path);
54
62
 
55
 
typedef xtBool (*XTFlushCacheFunc)(struct XTOpenFile *of);
56
 
 
57
63
typedef struct XTFile {
58
64
        u_int                           fil_ref_count;          /* The number of open file structure referencing this file. */
59
65
        char                            *fil_path;
61
67
#ifndef XT_WIN                                                          /* Windows does not have pread/pwrite functions! */
62
68
        int                                     fil_filedes;            /* The shared file descriptor (pread and pwrite allow this) */
63
69
#endif
64
 
        int                                     fil_mode;
65
70
} XTFileRec, *XTFilePtr;
66
71
 
67
72
typedef struct XTOpenFile {
72
77
#else
73
78
        int                                     of_filedes;
74
79
#endif
75
 
        XTFlushCacheFunc        of_flush;
76
80
} XTOpenFileRec, *XTOpenFilePtr;
77
81
 
78
82
void                    xt_fs_init(struct XTThread *self);
79
83
void                    xt_fs_exit(struct XTThread *self);
 
84
 
 
85
XTFilePtr               xt_fs_get_file(struct XTThread *self, char *file_name);
 
86
void                    xt_fs_release_file(struct XTThread *self, XTFilePtr file_ptr);
 
87
 
80
88
XTOpenFilePtr   xt_open_file(struct XTThread *self, char *file, int mode);
81
89
XTOpenFilePtr   xt_open_file_ns(char *file, int mode);
 
90
xtBool                  xt_open_file_ns(XTOpenFilePtr *fh, char *file, int mode);
82
91
void                    xt_close_file(struct XTThread *self, XTOpenFilePtr f);
83
92
xtBool                  xt_close_file_ns(XTOpenFilePtr f);
84
93
char                    *xt_file_path(XTOpenFilePtr of);