2 #define isSLASH(c) ((c) == '/' || (c) == '\\')
3 #define SKIP_SLASHES(s) \
5 while (*(s) && isSLASH(*(s))) \
8 #define COPY_NONSLASHES(d,s) \
10 while (*(s) && !isSLASH(*(s))) \
15 /* Find the longname of a given path. path is destructively modified.
16 * It should have space for at least MAX_PATH characters. */
19 LONGPATH(CHAR_T *path)
21 WIN32_FIND_DATA_T fdata;
23 CHAR_T tmpbuf[MAX_PATH+1];
24 CHAR_T *tmpstart = tmpbuf;
31 if (isALPHA(path[0]) && path[1] == ':') {
33 *tmpstart++ = toupper(path[0]);
37 else if (isSLASH(path[0]) && isSLASH(path[1])) {
39 *tmpstart++ = path[0];
40 *tmpstart++ = path[1];
42 COPY_NONSLASHES(tmpstart,start); /* copy machine name */
44 *tmpstart++ = *start++;
46 COPY_NONSLASHES(tmpstart,start); /* copy share name */
51 /* copy initial slash, if any */
52 if (isSLASH(*start)) {
53 *tmpstart++ = *start++;
58 /* FindFirstFile() expands "." and "..", so we need to pass
59 * those through unmolested */
61 && (!start[1] || isSLASH(start[1])
62 || (start[1] == '.' && (!start[2] || isSLASH(start[2])))))
64 COPY_NONSLASHES(tmpstart,start); /* copy "." or ".." */
69 /* if this is the end, bust outta here */
73 /* now we're at a non-slash; walk up to next slash */
74 while (*start && !isSLASH(*start))
77 /* stop and find full name of component */
80 fhand = FN_FINDFIRSTFILE(path,&fdata);
82 if (fhand != INVALID_HANDLE_VALUE) {
83 STRLEN len = FN_STRLEN(fdata.cFileName);
84 if ((STRLEN)(tmpbuf + sizeof(tmpbuf) - tmpstart) > len) {
85 FN_STRCPY(tmpstart, fdata.cFileName);
96 /* failed a step, just return without side effects */
97 /*PerlIO_printf(Perl_debug_log, "Failed to find %s\n", path);*/
102 FN_STRCPY(path,tmpbuf);
107 #undef WIN32_FIND_DATA_T
108 #undef FN_FINDFIRSTFILE