mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
dir.c: long path name on Windows
* dir.c (has_magic): always get long path name on Windows even if no tilde is there. [ruby-core:68011] [Bug #10819] * dir.c (replace_real_basename): FindFirstFile ignore redirection character, check if exists before call it. cf. [Bug #8597] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7645c974de
commit
034e38d8a2
2 changed files with 22 additions and 20 deletions
|
@ -1,3 +1,11 @@
|
|||
Sat Feb 7 19:25:25 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* dir.c (has_magic): always get long path name on Windows even if
|
||||
no tilde is there. [ruby-core:68011] [Bug #10819]
|
||||
|
||||
* dir.c (replace_real_basename): FindFirstFile ignore redirection
|
||||
character, check if exists before call it. cf. [Bug #8597]
|
||||
|
||||
Sat Feb 7 13:30:11 2015 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* test/win32ole/test_win32ole_record.rb
|
||||
|
|
34
dir.c
34
dir.c
|
@ -71,6 +71,9 @@ char *strchr(char*,char);
|
|||
#define rmdir(p) rb_w32_urmdir(p)
|
||||
#undef opendir
|
||||
#define opendir(p) rb_w32_uopendir(p)
|
||||
#define IS_WIN32 1
|
||||
#else
|
||||
#define IS_WIN32 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_ATTR_H
|
||||
|
@ -1210,28 +1213,17 @@ has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
|
|||
break;
|
||||
|
||||
#ifdef _WIN32
|
||||
case '~':
|
||||
/* possibly legacy 8.3 short name */
|
||||
if (p < pend && (c = *p, ISDIGIT(c))) {
|
||||
while (++p < pend && (c = *p, ISDIGIT(c)));
|
||||
if (p == pend || c == '.') hasalpha = 1;
|
||||
}
|
||||
continue;
|
||||
#endif
|
||||
case '.':
|
||||
break;
|
||||
|
||||
case '~':
|
||||
hasalpha = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
if (ISALPHA(c)) {
|
||||
if (IS_WIN32 || ISALPHA(c)) {
|
||||
hasalpha = 1;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if (!rb_isascii(c)) {
|
||||
unsigned int code = rb_enc_mbc_to_codepoint(p, pend, enc);
|
||||
if (ONIGENC_IS_CODE_ALPHA(enc, code)) {
|
||||
/* Full width alphabets */
|
||||
hasalpha = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1469,8 +1461,9 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p)
|
|||
char *plainname = path;
|
||||
volatile VALUE tmp = 0;
|
||||
WIN32_FIND_DATAW fd;
|
||||
WIN32_FILE_ATTRIBUTE_DATA fa;
|
||||
WCHAR *wplain;
|
||||
HANDLE h;
|
||||
HANDLE h = INVALID_HANDLE_VALUE;
|
||||
long wlen;
|
||||
if (enc &&
|
||||
enc != rb_usascii_encoding() &&
|
||||
|
@ -1483,7 +1476,8 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p)
|
|||
wplain = rb_w32_mbstr_to_wstr(CP_UTF8, plainname, -1, &wlen);
|
||||
if (tmp) rb_str_resize(tmp, 0);
|
||||
if (!wplain) return path;
|
||||
h = FindFirstFileW(wplain, &fd);
|
||||
if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa))
|
||||
h = FindFirstFileW(wplain, &fd);
|
||||
free(wplain);
|
||||
if (h == INVALID_HANDLE_VALUE) return path;
|
||||
FindClose(h);
|
||||
|
|
Loading…
Reference in a new issue