Rev 5064 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5064 | Rev 5076 | ||
---|---|---|---|
Line 912... | Line 912... | ||
912 | #ifdef FILENAME_CASE_CHECK
|
912 | #ifdef FILENAME_CASE_CHECK
|
913 | // See
|
913 | // See
|
914 | // http://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows
|
914 | // http://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows
|
915 | // for relevant discussion.
|
915 | // for relevant discussion.
|
916 | 916 | ||
917 | static SHFILEINFO shinf; |
917 | static char fnbuf[BMAX_PATH]; |
- | 918 | int fnofs; |
|
918 | 919 | ||
919 | int32_t (*check_filename_casing_fn)(void) = NULL; |
920 | int32_t (*check_filename_casing_fn)(void) = NULL; |
920 | 921 | ||
921 | // -1: failure, 0: match, 1: mismatch
|
922 | // -1: failure, 0: match, 1: mismatch
|
922 | static int32_t check_filename_mismatch(const char *filename, int32_t ofs) |
923 | static int32_t check_filename_mismatch(const char * const filename, int ofs) |
923 | {
|
924 | {
|
924 | const char *fn = filename+ofs; |
925 | if (!GetShortPathNameA(filename, fnbuf, BMAX_PATH)) return -1; |
925 | int32_t len; |
926 | if (!GetLongPathNameA(fnbuf, fnbuf, BMAX_PATH)) return -1; |
926 | 927 | ||
927 | // we assume that UNICODE is not #defined, winlayer.c errors out else
|
- | |
928 | if (!SHGetFileInfo(filename, -1, &shinf, sizeof(shinf), SHGFI_DISPLAYNAME)) |
- | |
929 | return -1; |
928 | fnofs = ofs; |
930 | 929 | ||
931 | len = Bstrlen(shinf.szDisplayName); |
930 | int len = Bstrlen(fnbuf+ofs); |
932 | 931 | ||
- | 932 | char const * const fn = filename+ofs; |
|
- | 933 | ||
933 | if (!Bstrncmp(shinf.szDisplayName, fn, len)) |
934 | if (!Bstrncmp(fnbuf+ofs, fn, len)) |
934 | return 0; |
935 | return 0; |
935 | 936 | ||
936 | {
|
- | |
937 | char *tfn = Bstrtolower(Xstrdup(fn)); |
937 | char * const tfn = Bstrtolower(Xstrdup(fn)); |
938 | 938 | ||
939 | if (!Bstrncmp(shinf.szDisplayName, tfn, len)) |
939 | if (!Bstrncmp(fnbuf+ofs, tfn, len)) |
940 | {
|
940 | {
|
941 | Bfree(tfn); |
941 | Bfree(tfn); |
942 | return 0; |
942 | return 0; |
943 | }
|
943 | }
|
944 | 944 | ||
945 | Bstrupr(tfn); |
945 | Bstrupr(tfn); |
946 | 946 | ||
947 | if (!Bstrncmp(shinf.szDisplayName, tfn, len)) |
947 | if (!Bstrncmp(fnbuf+ofs, tfn, len)) |
948 | {
|
948 | {
|
949 | Bfree(tfn); |
949 | Bfree(tfn); |
950 | return 0; |
950 | return 0; |
951 | }
|
951 | }
|
952 | 952 | ||
953 | Bfree(tfn); |
953 | Bfree(tfn); |
954 | }
|
- | |
955 | 954 | ||
956 | return 1; |
955 | return 1; |
957 | }
|
956 | }
|
958 | #endif
|
957 | #endif
|
959 | 958 | ||
Line 990... | Line 989... | ||
990 | // initprintf("SHGetFileInfo failed with error code %lu\n", GetLastError());
|
989 | // initprintf("SHGetFileInfo failed with error code %lu\n", GetLastError());
|
991 | }
|
990 | }
|
992 | else if (status == 1) |
991 | else if (status == 1) |
993 | {
|
992 | {
|
994 | initprintf("warning: case mismatch: passed \"%s\", real \"%s\"\n", |
993 | initprintf("warning: case mismatch: passed \"%s\", real \"%s\"\n", |
995 | lastslash, shinf.szDisplayName); |
994 | lastslash, fnbuf+fnofs); |
996 | }
|
995 | }
|
997 | }
|
996 | }
|
998 | #else
|
997 | #else
|
999 | UNREFERENCED_PARAMETER(checkcase); |
998 | UNREFERENCED_PARAMETER(checkcase); |
1000 | #endif
|
999 | #endif
|