diff options
| author | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-20 14:50:43 +0000 |
|---|---|---|
| committer | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-20 14:50:43 +0000 |
| commit | f004590693659f02c34d773378b8688c1f5137e0 (patch) | |
| tree | 746da3082dfbaf897b1a71cf52a4ba29e716f7d3 /win32 | |
| parent | 5ab2b8a553950333ff98642a4e4c8d8d3d87f4b8 (diff) | |
| download | ruby-f004590693659f02c34d773378b8688c1f5137e0.tar.gz ruby-f004590693659f02c34d773378b8688c1f5137e0.tar.xz ruby-f004590693659f02c34d773378b8688c1f5137e0.zip | |
* win32/win32.c (win32_stat): UNC support.
* dir.c (extract_path): fix "./*" problem.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/win32.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/win32/win32.c b/win32/win32.c index e170f1b22..da657a540 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2668,23 +2668,29 @@ myrename(const char *oldpath, const char *newpath) int win32_stat(const char *path, struct stat *st) { - const char *p = path; - int ret; + const char *p; + char *buf1 = ALLOCA_N(char, strlen(path) + 1); + char *buf2 = ALLOCA_N(char, MAXPATHLEN); + char *s; + int len; - if ((isdirsep(*p) && (p++, TRUE)) || /* absolute path or UNC */ - (ISALPHA(*p) && p[1] == ':' && (p += 2, TRUE))) { /* has drive */ - if (isdirsep(*p)) p++; - } - if (*p && (p = CharPrev(p, p + strlen(p)), isdirsep(*p))) { - /* Win95/2000 fail with trailing path separator? */ - int len = p - path; - char *s = ALLOCA_N(char, len + 1); - memcpy(s, path, len); - s[len] = '\0'; - path = s; - } - RUBY_CRITICAL(ret = stat(path, st)); - return ret; + for (p = path, s = buf1; *p; p++, s++) { + if (*p == '/') + *s = '\\'; + else + *s = *p; + } + *s = '\0'; + len = strlen(buf1); + p = CharPrev(buf1, buf1 + len); + if (*p == '\\' || *p == ':') + strcat(buf1, "."); + else if (buf1[0] == '\\' && buf1[1] == '\\') + strcat(buf1, "\\."); + if (_fullpath(buf2, buf1, MAXPATHLEN)) + return stat(buf2, st); + else + return -1; } static long |
