mirror of https://github.com/mgba-emu/mgba.git
Updater: Fix existing directory update logic
This commit is contained in:
parent
ec52154112
commit
5534d23690
|
@ -93,10 +93,11 @@ bool extractArchive(struct VDir* archive, const char* root, bool prefix) {
|
|||
case VFS_DIRECTORY:
|
||||
fprintf(logfile, "mkdir %s\n", fname);
|
||||
if (mkdir(path, 0755) < 0) {
|
||||
bool redo = false;
|
||||
if (errno == EEXIST) {
|
||||
bool redo = true;
|
||||
struct stat st;
|
||||
if (stat(path, &st) >= 0 && !S_ISDIR(st.st_mode)) {
|
||||
if (errno != EEXIST || stat(path, &st) < 0) {
|
||||
redo = false;
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
#ifdef _WIN32
|
||||
wchar_t wpath[MAX_PATH + 1];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH);
|
||||
|
@ -104,9 +105,8 @@ bool extractArchive(struct VDir* archive, const char* root, bool prefix) {
|
|||
#else
|
||||
unlink(path);
|
||||
#endif
|
||||
if (mkdir(path, 0755) >= 0) {
|
||||
redo = true;
|
||||
}
|
||||
if (mkdir(path, 0755) < 0) {
|
||||
redo = false;
|
||||
}
|
||||
}
|
||||
if (!redo) {
|
||||
|
|
Loading…
Reference in New Issue