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); |