aboutsummaryrefslogtreecommitdiff
path: root/coreutils/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/test.c')
-rw-r--r--coreutils/test.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 2d245be6c..cb15ed725 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -619,6 +619,33 @@ static int filstat(char *nm, enum token mode)
619 return 0; 619 return 0;
620 } 620 }
621 621
622#if ENABLE_PLATFORM_MINGW32
623#undef R_OK
624#define R_OK S_IREAD
625#undef W_OK
626#define W_OK S_IWRITE
627 if (mode == FILEX) {
628 int len = strlen(nm), ret;
629 if (len >= 4 &&
630 (!strcmp(nm+len-4,".exe") ||
631 !strcmp(nm+len-4,".com")))
632 ret = stat(nm, &s);
633 else {
634 char *exepath;
635 exepath = malloc(len+5);
636 memcpy(exepath, nm, len);
637 memcpy(exepath+len, ".exe", 5);
638 ret = stat(exepath, &s);
639 if (ret < 0) {
640 memcpy(exepath+len, ".exe", 5);
641 ret = stat(exepath, &s);
642 }
643 free(exepath);
644 }
645 return ret >= 0;
646 }
647#endif
648
622 if (stat(nm, &s) != 0) 649 if (stat(nm, &s) != 0)
623 return 0; 650 return 0;
624 if (mode == FILEXIST) 651 if (mode == FILEXIST)