Commit | Line | Data |
---|---|---|
0a753a76 | 1 | /* |
2 | * Globbing for NT. Relies on the expansion done by the library | |
8f550399 | 3 | * startup code (provided by Visual C++ by linking in setargv.obj). |
0a753a76 | 4 | */ |
5 | ||
8f550399 SH |
6 | /* Enable wildcard expansion for gcc's C-runtime library if not enabled by |
7 | * default (currently necessary with the automated build of the mingw-w64 | |
8 | * cross-compiler, but there's no harm in making sure for others too). */ | |
9 | #ifdef __MINGW32__ | |
10 | #include <_mingw.h> | |
11 | #if defined(__MINGW64_VERSION_MAJOR) && defined(__MINGW64_VERSION_MINOR) | |
12 | // MinGW-w64 | |
13 | int _dowildcard = -1; | |
14 | #else | |
15 | // MinGW | |
16 | int _CRT_glob = -1; | |
17 | #endif | |
18 | #endif | |
19 | ||
0a753a76 | 20 | #include <stdio.h> |
21 | #include <io.h> | |
22 | #include <fcntl.h> | |
23 | #include <string.h> | |
24 | #include <windows.h> | |
25 | ||
26 | int | |
27 | main(int argc, char *argv[]) | |
28 | { | |
29 | int i; | |
c623ac67 | 30 | size_t len; |
0a753a76 | 31 | char root[MAX_PATH]; |
32 | char *dummy; | |
33 | char volname[MAX_PATH]; | |
34 | DWORD serial, maxname, flags; | |
35 | BOOL downcase = TRUE; | |
36 | ||
37 | /* check out the file system characteristics */ | |
0a753a76 | 38 | if (GetFullPathName(".", MAX_PATH, root, &dummy)) { |
161b471a NIS |
39 | dummy = strchr(root,'\\'); |
40 | if (dummy) | |
0a753a76 | 41 | *++dummy = '\0'; |
42 | if (GetVolumeInformation(root, volname, MAX_PATH, | |
43 | &serial, &maxname, &flags, 0, 0)) { | |
44 | downcase = !(flags & FS_CASE_IS_PRESERVED); | |
45 | } | |
46 | } | |
47 | ||
3e3baf6d | 48 | setmode(fileno(stdout), O_BINARY); |
0a753a76 | 49 | for (i = 1; i < argc; i++) { |
50 | len = strlen(argv[i]); | |
51 | if (downcase) | |
52 | strlwr(argv[i]); | |
53 | if (i > 1) fwrite("\0", sizeof(char), 1, stdout); | |
54 | fwrite(argv[i], sizeof(char), len, stdout); | |
55 | } | |
56 | return 0; | |
57 | } | |
161b471a | 58 |