* Compares two Unicode strings using natural human ordering. * @param a String A. * @param b String B. * @return String A comes before String B. */
| 849 | * @return String A comes before String B. |
| 850 | */ |
| 851 | bool naturalCompare(const std::wstring &a, const std::wstring &b) |
| 852 | { |
| 853 | #if defined(_WIN32) && (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR)) |
| 854 | return (StrCmpLogicalW(a.c_str(), b.c_str()) < 0); |
| 855 | #else |
| 856 | // sorry unix users you get ASCII sort |
| 857 | std::wstring::const_iterator i, j; |
| 858 | for (i = a.begin(), j = b.begin(); i != a.end() && j != b.end() && tolower(*i) == tolower(*j); i++, j++); |
| 859 | return (i != a.end() && j != b.end() && tolower(*i) < tolower(*j)); |
| 860 | #endif |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * Moves a file from one path to another, |