comparison perl-5.22.2/win32/perlglob.c @ 8045:a16537d2fe07

<xfix> tar xf perl-5.22.2.tar.gz # Ah, whatever, I\'m doing it anyway
author HackBot
date Sat, 14 May 2016 14:54:38 +0000
parents
children
comparison
equal deleted inserted replaced
8044:711c038a7dce 8045:a16537d2fe07
1 /*
2 * Globbing for NT. Relies on the expansion done by the library
3 * startup code (provided by Visual C++ by linking in setargv.obj).
4 */
5
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
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;
30 size_t len;
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 */
38 if (GetFullPathName(".", MAX_PATH, root, &dummy)) {
39 dummy = strchr(root,'\\');
40 if (dummy)
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
48 setmode(fileno(stdout), O_BINARY);
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 }
58