Changes in uspace/app/bdsh/cmds/modules/rm/rm.c [afe1d1e:ed2c8ff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/rm/rm.c
rafe1d1e red2c8ff 101 101 } 102 102 103 static unsigned int rm_recursive_not_empty_dirs(const char *path) 104 { 105 DIR *dirp; 106 struct dirent *dp; 107 char buff[PATH_MAX]; 108 unsigned int scope; 109 unsigned int ret = 0; 110 111 dirp = opendir(path); 112 if (!dirp) { 113 /* May have been deleted between scoping it and opening it */ 114 cli_error(CL_EFAIL, "Could not open %s", path); 115 return ret; 116 } 117 118 memset(buff, 0, sizeof(buff)); 119 while ((dp = readdir(dirp))) { 120 snprintf(buff, PATH_MAX - 1, "%s/%s", path, dp->d_name); 121 scope = rm_scope(buff); 122 switch (scope) { 123 case RM_BOGUS: 124 break; 125 case RM_FILE: 126 ret += rm_single(buff); 127 break; 128 case RM_DIR: 129 ret += rm_recursive(buff); 130 break; 131 } 132 } 133 134 return ret; 135 } 136 103 137 static unsigned int rm_recursive(const char *path) 104 138 { 105 139 int rc; 140 unsigned int ret = 0; 106 141 107 142 /* First see if it will just go away */ … … 111 146 112 147 /* Its not empty, recursively scan it */ 113 cli_error(CL_ENOTSUP, 114 "Can not remove %s, directory not empty", path); 115 return 1; 148 ret = rm_recursive_not_empty_dirs(path); 149 150 /* Delete directory */ 151 rc = rmdir(path); 152 if (rc == 0) 153 return ret; 154 155 cli_error(CL_ENOTSUP, "Can not remove %s", path); 156 157 return ret + 1; 116 158 } 117 159
Note:
See TracChangeset
for help on using the changeset viewer.