1 // 2 // aegis - project change supervisor 3 // Copyright (C) 2001, 2002, 2004-2006, 2008 Peter Miller 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see 17 // <http://www.gnu.org/licenses/>. 18 // 19 20 #include <common/ac/stddef.h> 21 #include <common/ac/sys/types.h> 22 #include <common/ac/sys/stat.h> 23 #include <common/ac/stdlib.h> 24 25 #include <libaegis/dir.h> 26 #include <libaegis/dir/functor/rmdir_bg.h> 27 #include <common/error.h> 28 #include <libaegis/glue.h> 29 #include <libaegis/lock.h> 30 #include <libaegis/os.h> 31 #include <libaegis/undo.h> 32 33 34 int rmdir_bg(const char * path)35rmdir_bg(const char *path) 36 { 37 switch (fork()) 38 { 39 case -1: 40 nfatal("fork"); 41 42 case 0: 43 { 44 // child 45 os_interrupt_ignore(); 46 lock_release_child(); // don't hold locks 47 undo_cancel(); // don't do anything else! 48 dir_functor_rmdir_bg eraser; 49 dir_walk(nstring(path), eraser); 50 exit(0); 51 } 52 53 default: 54 // parent 55 break; 56 } 57 return 0; 58 } 59 60 61 int rmdir_tree(const char * path)62rmdir_tree(const char *path) 63 { 64 dir_functor_rmdir_bg eraser; 65 dir_walk(nstring(path), eraser); 66 return 0; 67 } 68