src/server/test/vfs.c

changeset 490
d218607f5a7e
parent 415
d938228c382e
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
301 301
302 if(file->isdir) { 302 if(file->isdir) {
303 return 1; 303 return 1;
304 } 304 }
305 305
306 (void)cxMapRemove(vfs->files, path_key); 306 cxMapRemove(vfs->files, path_key);
307 vfs->count_unlink++; 307 vfs->count_unlink++;
308 return 0; 308 return 0;
309 } 309 }
310 310
311 int testvfs_rmdir(VFSContext *ctx, const char *path) { 311 int testvfs_rmdir(VFSContext *ctx, const char *path) {
326 if(f->path.length > dir->path.length && cx_strprefix(cx_strcast(f->path), cx_strcast(dir->path))){ 326 if(f->path.length > dir->path.length && cx_strprefix(cx_strcast(f->path), cx_strcast(dir->path))){
327 return 1; // dir not empty 327 return 1; // dir not empty
328 } 328 }
329 } 329 }
330 330
331 (void)cxMapRemove(vfs->files, path_key); 331 cxMapRemove(vfs->files, path_key);
332 vfs->count_rmdir++; 332 vfs->count_rmdir++;
333 return 0; 333 return 0;
334 } 334 }
335 335
336 static VFS testVFSClass = { 336 static VFS testVFSClass = {
349 349
350 VFS* testvfs_create(Session *sn) { 350 VFS* testvfs_create(Session *sn) {
351 TestVFS *vfs = pool_malloc(sn->pool, sizeof(TestVFS)); 351 TestVFS *vfs = pool_malloc(sn->pool, sizeof(TestVFS));
352 vfs->count_unlink = 0; 352 vfs->count_unlink = 0;
353 vfs->count_rmdir = 0; 353 vfs->count_rmdir = 0;
354 vfs->files = cxHashMapCreate(pool_allocator(sn->pool), 64); 354 vfs->files = cxHashMapCreate(pool_allocator(sn->pool), CX_STORE_POINTERS, 64);
355 355
356 testVFSClass.instance = vfs; 356 testVFSClass.instance = vfs;
357 return &testVFSClass; 357 return &testVFSClass;
358 } 358 }
359 359
445 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed"); 445 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed");
446 446
447 VFSDir *dir = vfs_opendir(vfs, "/dir"); 447 VFSDir *dir = vfs_opendir(vfs, "/dir");
448 UCX_TEST_ASSERT(dir, "dir not opened"); 448 UCX_TEST_ASSERT(dir, "dir not opened");
449 449
450 CxMap *files = cxHashMapCreate(cxDefaultAllocator, 8); 450 CxMap *files = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8);
451 451
452 VFSEntry entry; 452 VFSEntry entry;
453 while(vfs_readdir(dir, &entry)) { 453 while(vfs_readdir(dir, &entry)) {
454 cxMapPut(files, cx_hash_key_str(entry.name), dir); 454 cxMapPut(files, cx_hash_key_str(entry.name), dir);
455 } 455 }

mercurial