src/server/test/vfs.c

branch
webdav
changeset 241
4adad7faf452
parent 220
2915b6c11aec
child 248
bc8f8ddbad2e
equal deleted inserted replaced
240:cd74667f6c85 241:4adad7faf452
111 }; 111 };
112 112
113 113
114 /* vfs funcs */ 114 /* vfs funcs */
115 115
116 SYS_FILE testvfs_open(VFSContext *ctx, char *path, int oflags) { 116 SYS_FILE testvfs_open(VFSContext *ctx, const char *path, int oflags) {
117 TestVFS *vfs = ctx->vfs->instance; 117 TestVFS *vfs = ctx->vfs->instance;
118 TestVFSFile *file = NULL; 118 TestVFSFile *file = NULL;
119 119
120 sstr_t s_path = sstr(path); 120 sstr_t s_path = sstr((char*)path);
121 if(sstrsuffix(s_path, S("/"))) { 121 if(sstrsuffix(s_path, S("/"))) {
122 s_path.length--; 122 s_path.length--;
123 } 123 }
124 124
125 file = ucx_map_sstr_get(vfs->files, s_path); 125 file = ucx_map_sstr_get(vfs->files, s_path);
134 } 134 }
135 135
136 return (SYS_FILE)file; 136 return (SYS_FILE)file;
137 } 137 }
138 138
139 int testvfs_stat(VFSContext *ctx, char *path, struct stat *buf) { 139 int testvfs_stat(VFSContext *ctx, const char *path, struct stat *buf) {
140 TestVFS *vfs = ctx->vfs->instance; 140 TestVFS *vfs = ctx->vfs->instance;
141 TestVFSFile *file = NULL; 141 TestVFSFile *file = NULL;
142 142
143 sstr_t s_path = sstr(path); 143 sstr_t s_path = sstr((char*)path);
144 if(sstrsuffix(s_path, S("/"))) { 144 if(sstrsuffix(s_path, S("/"))) {
145 s_path.length--; 145 s_path.length--;
146 } 146 }
147 147
148 file = ucx_map_sstr_get(vfs->files, s_path); 148 file = ucx_map_sstr_get(vfs->files, s_path);
154 154
155 int testvfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) { 155 int testvfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) {
156 return 0; 156 return 0;
157 } 157 }
158 158
159 VFS_DIR testvfs_opendir(VFSContext *ctx, char *path) { 159 VFS_DIR testvfs_opendir(VFSContext *ctx, const char *path) {
160 TestVFS *vfs = ctx->vfs->instance; 160 TestVFS *vfs = ctx->vfs->instance;
161 TestVFSFile *file = NULL; 161 TestVFSFile *file = NULL;
162 162
163 sstr_t s_path = sstr(path); 163 sstr_t s_path = sstr((char*)path);
164 if(sstrsuffix(s_path, S("/"))) { 164 if(sstrsuffix(s_path, S("/"))) {
165 s_path.length--; 165 s_path.length--;
166 } 166 }
167 167
168 file = ucx_map_sstr_get(vfs->files, s_path); 168 file = ucx_map_sstr_get(vfs->files, s_path);
201 dir->dir.io = &test_dir_io; 201 dir->dir.io = &test_dir_io;
202 202
203 return (VFS_DIR)dir; 203 return (VFS_DIR)dir;
204 } 204 }
205 205
206 int testvfs_mkdir(VFSContext *ctx, char *path) { 206 int testvfs_mkdir(VFSContext *ctx, const char *path) {
207 SYS_FILE fd = testvfs_open(ctx, path, O_CREAT); 207 SYS_FILE fd = testvfs_open(ctx, path, O_CREAT);
208 if(!fd) { 208 if(!fd) {
209 return 1; 209 return 1;
210 } 210 }
211 211
213 file->isdir = 1; 213 file->isdir = 1;
214 214
215 return 0; 215 return 0;
216 } 216 }
217 217
218 int testvfs_unlink(VFSContext *ctx, char *path) { 218 int testvfs_unlink(VFSContext *ctx, const char *path) {
219 return 0; 219 return 0;
220 } 220 }
221 221
222 static VFS testVFSClass = { 222 static VFS testVFSClass = {
223 testvfs_open, 223 testvfs_open,

mercurial