src/server/webdav/webdav.c

branch
webdav
changeset 246
155bdef7fe7e
parent 245
a193c42fc809
child 247
1df803e06076
equal deleted inserted replaced
245:a193c42fc809 246:155bdef7fe7e
44 #include "../util/pblock.h" 44 #include "../util/pblock.h"
45 #include "../util/util.h" 45 #include "../util/util.h"
46 #include "../daemon/session.h" 46 #include "../daemon/session.h"
47 #include "../daemon/http.h" 47 #include "../daemon/http.h"
48 #include "../daemon/protocol.h" 48 #include "../daemon/protocol.h"
49 #include "../daemon/vfs.h"
49 50
50 static UcxMap *method_handler_map; 51 static UcxMap *method_handler_map;
51 52
52 static WebdavBackend default_backend; 53 static WebdavBackend default_backend;
53 54
458 459
459 int webdav_post(pblock *pb, Session *sn, Request *rq) { 460 int webdav_post(pblock *pb, Session *sn, Request *rq) {
460 return REQ_ABORTED; 461 return REQ_ABORTED;
461 } 462 }
462 463
463 static int webdav_delete_collection( 464 static int webdav_delete_collection(WebdavVFSOperation *op)
464 Session *sn, 465 {
465 Request *rq, 466 // TODO
466 VFSContext *vfs,
467 const char *path)
468 {
469
470 } 467 }
471 468
472 int webdav_delete(pblock *pb, Session *sn, Request *rq) { 469 int webdav_delete(pblock *pb, Session *sn, Request *rq) {
473 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE); 470 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE);
474 if(!op) { 471 if(!op) {
475 return REQ_ABORTED; 472 return REQ_ABORTED;
476 } 473 }
477 474
478 int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR); 475 // stat to find out if the resource is a collection
476 struct stat s;
477 if(vfs_stat(op->vfs, op->path, &s)) {
478 sys_set_error_status(op->vfs);
479 return REQ_ABORTED;
480 }
481
482 int ret;
483 if(S_ISDIR(s.st_mode)) {
484 ret = webdav_delete_collection(op);
485 } else {
486 ret = webdav_vfs_op_do(op, WEBDAV_VFS_DELETE);
487 }
479 488
480 return ret; 489 return ret;
481 } 490 }
482 491
483 int webdav_put(pblock *pb, Session *sn, Request *rq) { 492 int webdav_put(pblock *pb, Session *sn, Request *rq) {

mercurial