diff options
Diffstat (limited to 'coreutils/test.c')
-rw-r--r-- | coreutils/test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index 1f5398ad8..2e896f4c7 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -642,6 +642,33 @@ static int filstat(char *nm, enum token mode) | |||
642 | return 0; | 642 | return 0; |
643 | } | 643 | } |
644 | 644 | ||
645 | #if ENABLE_PLATFORM_MINGW32 | ||
646 | #undef R_OK | ||
647 | #define R_OK S_IREAD | ||
648 | #undef W_OK | ||
649 | #define W_OK S_IWRITE | ||
650 | if (mode == FILEX) { | ||
651 | int len = strlen(nm), ret; | ||
652 | if (len >= 4 && | ||
653 | (!strcmp(nm+len-4,".exe") || | ||
654 | !strcmp(nm+len-4,".com"))) | ||
655 | ret = stat(nm, &s); | ||
656 | else { | ||
657 | char *exepath; | ||
658 | exepath = malloc(len+5); | ||
659 | memcpy(exepath, nm, len); | ||
660 | memcpy(exepath+len, ".exe", 5); | ||
661 | ret = stat(exepath, &s); | ||
662 | if (ret < 0) { | ||
663 | memcpy(exepath+len, ".exe", 5); | ||
664 | ret = stat(exepath, &s); | ||
665 | } | ||
666 | free(exepath); | ||
667 | } | ||
668 | return ret >= 0; | ||
669 | } | ||
670 | #endif | ||
671 | |||
645 | if (stat(nm, &s) != 0) | 672 | if (stat(nm, &s) != 0) |
646 | return 0; | 673 | return 0; |
647 | if (mode == FILEXIST) | 674 | if (mode == FILEXIST) |