454 { |
470 { |
455 UcxAllocator *a = session_get_allocator(vfs->sn); |
471 UcxAllocator *a = session_get_allocator(vfs->sn); |
456 pool_handle_t *pool = vfs->sn->pool; |
472 pool_handle_t *pool = vfs->sn->pool; |
457 |
473 |
458 PathSearchElm *start_elm = pool_malloc(pool, sizeof(PathSearchElm)); |
474 PathSearchElm *start_elm = pool_malloc(pool, sizeof(PathSearchElm)); |
459 start_elm->href = pool_strdup(pool, href); |
475 start_elm->href = pool_strdup(pool, href ? href : ""); |
460 start_elm->path = pool_strdup(pool, path); |
476 start_elm->path = pool_strdup(pool, path ? path : ""); |
461 start_elm->hreflen = strlen(href); |
477 start_elm->hreflen = href ? strlen(href) : 0; |
462 start_elm->pathlen = strlen(path); |
478 start_elm->pathlen = path ? strlen(path) : 0; |
463 |
479 |
464 UcxList *stack = ucx_list_prepend_a(a, NULL, start_elm); |
480 UcxList *stack = ucx_list_prepend_a(a, NULL, start_elm); |
465 UcxList *stack_end = stack; |
481 UcxList *stack_end = stack; |
466 if(!stack) { |
482 if(!stack) { |
467 return 1; |
483 return 1; |
722 return ret; |
738 return ret; |
723 } |
739 } |
724 |
740 |
725 int webdav_vfs_unlink(WebdavVFSOperation *op) { |
741 int webdav_vfs_unlink(WebdavVFSOperation *op) { |
726 // stat the file first, to check if the file is a directory |
742 // stat the file first, to check if the file is a directory |
727 // deletion of simple files can be done just here, |
|
728 // whereas deleting directories is more complicated |
|
729 if(webdav_vfs_stat(op)) { |
743 if(webdav_vfs_stat(op)) { |
730 return 1; // error |
744 return 1; // error |
731 } else { |
745 } else { |
732 int r = 0; |
|
733 if(!S_ISDIR(op->stat->st_mode)) { |
746 if(!S_ISDIR(op->stat->st_mode)) { |
734 return vfs_unlink(op->vfs, op->path); |
747 return vfs_unlink(op->vfs, op->path); |
735 } |
748 } else { |
736 } |
749 return vfs_rmdir(op->vfs, op->path); |
737 |
750 } |
738 // delete directory: |
751 } |
739 |
|
740 |
|
741 |
752 |
742 return 0; |
753 return 0; |
743 } |
754 } |