| 247 | } |
| 248 | |
| 249 | int removePath(const char *path, FileProcessParam *param) { |
| 250 | SceUID dfd = sceIoDopen(path); |
| 251 | if (dfd >= 0) { |
| 252 | int res = 0; |
| 253 | |
| 254 | do { |
| 255 | SceIoDirent dir; |
| 256 | memset(&dir, 0, sizeof(SceIoDirent)); |
| 257 | |
| 258 | res = sceIoDread(dfd, &dir); |
| 259 | if (res > 0) { |
| 260 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2); |
| 261 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name); |
| 262 | |
| 263 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) { |
| 264 | int ret = removePath(new_path, param); |
| 265 | if (ret <= 0) { |
| 266 | free(new_path); |
| 267 | sceIoDclose(dfd); |
| 268 | return ret; |
| 269 | } |
| 270 | } else { |
| 271 | int ret = sceIoRemove(new_path); |
| 272 | if (ret < 0) { |
| 273 | free(new_path); |
| 274 | sceIoDclose(dfd); |
| 275 | return ret; |
| 276 | } |
| 277 | |
| 278 | if (param) { |
| 279 | if (param->value) |
| 280 | (*param->value)++; |
| 281 | |
| 282 | if (param->SetProgress) |
| 283 | param->SetProgress(param->value ? *param->value : 0, param->max); |
| 284 | |
| 285 | if (param->cancelHandler && param->cancelHandler()) { |
| 286 | free(new_path); |
| 287 | sceIoDclose(dfd); |
| 288 | return 0; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | free(new_path); |
| 294 | } |
| 295 | } while (res > 0); |
| 296 | |
| 297 | sceIoDclose(dfd); |
| 298 | |
| 299 | int ret = sceIoRmdir(path); |
| 300 | if (ret < 0) |
| 301 | return ret; |
| 302 | |
| 303 | if (param) { |
| 304 | if (param->value) |
| 305 | (*param->value)++; |
| 306 |
no test coverage detected