|
@@ -59,26 +59,11 @@ int SDL_SYS_RemovePath(const char *path)
|
|
|
{
|
|
|
int rc = remove(path);
|
|
|
if (rc < 0) {
|
|
|
- const int origerrno = errno;
|
|
|
- if (origerrno == ENOENT) {
|
|
|
- char *parent = SDL_strdup(path);
|
|
|
- if (!parent) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- char *ptr = SDL_strrchr(parent, '/');
|
|
|
- if (ptr) {
|
|
|
- *ptr = '\0'; // chop off thing we were removing, see if parent is there.
|
|
|
- }
|
|
|
-
|
|
|
- struct stat statbuf;
|
|
|
- rc = stat(ptr ? parent : ".", &statbuf);
|
|
|
- SDL_free(parent);
|
|
|
- if (rc == 0) {
|
|
|
- return 0; // it's already gone, and parent exists, consider it success.
|
|
|
- }
|
|
|
+ if (errno == ENOENT) {
|
|
|
+ // It's already gone, this is a success
|
|
|
+ return 0;
|
|
|
}
|
|
|
- return SDL_SetError("Can't remove path: %s", strerror(origerrno));
|
|
|
+ return SDL_SetError("Can't remove path: %s", strerror(errno));
|
|
|
}
|
|
|
return 0;
|
|
|
}
|