Skip to content

Commit

Permalink
added sorting for file paths [formatting fixed] (#43)
Browse files Browse the repository at this point in the history
On windows32, `opendir(dirpath.c_str());` will return the files in alphabetical ordering.

However, when built on gcc, `opendir(dirpath.c_str());` will not return the files in alphabetical order.

Unfortunately, dandere2x needs the files to be in alphabetical order to work. 

The change is really small and shouldn't affect overall performance.

Built and tested on Manjaro 18.04 and gcc 9.1.0

[fixed edit]

- Maintained coding style
  • Loading branch information
akai-katto authored and nihui committed Sep 3, 2019
1 parent c11d4f4 commit f3628c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/filesystem_utils.h
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

#if _WIN32
#include <windows.h>
Expand Down Expand Up @@ -51,6 +52,7 @@ static int list_directory(const path_t& dirpath, std::vector<path_t>& imagepaths
}

_wclosedir(dir);
std::sort(imagepaths.begin(), imagepaths.end());

return 0;
}
Expand Down Expand Up @@ -84,6 +86,7 @@ static int list_directory(const path_t& dirpath, std::vector<path_t>& imagepaths
}

closedir(dir);
std::sort(imagepaths.begin(), imagepaths.end());

return 0;
}
Expand Down

0 comments on commit f3628c4

Please sign in to comment.