Changes in uspace/app/bdsh/cmds/modules/rm/rm.c [ed2c8ff:afe1d1e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/rm/rm.c
red2c8ff rafe1d1e 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 137 103 static unsigned int rm_recursive(const char *path) 138 104 { 139 105 int rc; 140 unsigned int ret = 0;141 106 142 107 /* First see if it will just go away */ … … 146 111 147 112 /* Its not empty, recursively scan it */ 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; 113 cli_error(CL_ENOTSUP, 114 "Can not remove %s, directory not empty", path); 115 return 1; 158 116 } 159 117
Note:
See TracChangeset
for help on using the changeset viewer.