win32.c: fallback to WCHAR-version in MSVCRT
* win32/win32.c (rb_w32_open): should not fallback to ANSI-version in MSVCRT, fallback to WCHAR-version in rb_w32_wopen instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e84f98d0d
commit
f213f5044e
@ -5975,19 +5975,7 @@ check_if_wdir(const WCHAR *wfile)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
static int w32_wopen(const WCHAR *file, int oflag, int perm);
|
||||||
static int
|
|
||||||
check_if_dir(const char *file)
|
|
||||||
{
|
|
||||||
WCHAR *wfile;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!(wfile = filecp_to_wstr(file, NULL)))
|
|
||||||
return FALSE;
|
|
||||||
ret = check_if_wdir(wfile);
|
|
||||||
free(wfile);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
int
|
int
|
||||||
@ -6002,16 +5990,9 @@ rb_w32_open(const char *file, int oflag, ...)
|
|||||||
pmode = va_arg(arg, int);
|
pmode = va_arg(arg, int);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
|
||||||
if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
|
|
||||||
oflag &= ~O_SHARE_DELETE;
|
|
||||||
ret = _open(file, oflag, pmode);
|
|
||||||
if (ret == -1 && errno == EACCES) check_if_dir(file);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(wfile = filecp_to_wstr(file, NULL)))
|
if (!(wfile = filecp_to_wstr(file, NULL)))
|
||||||
return -1;
|
return -1;
|
||||||
ret = rb_w32_wopen(wfile, oflag, pmode);
|
ret = w32_wopen(wfile, oflag, pmode);
|
||||||
free(wfile);
|
free(wfile);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -6019,6 +6000,21 @@ rb_w32_open(const char *file, int oflag, ...)
|
|||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
int
|
int
|
||||||
rb_w32_wopen(const WCHAR *file, int oflag, ...)
|
rb_w32_wopen(const WCHAR *file, int oflag, ...)
|
||||||
|
{
|
||||||
|
int pmode = 0;
|
||||||
|
|
||||||
|
if (oflag & O_CREAT) {
|
||||||
|
va_list arg;
|
||||||
|
va_start(arg, oflag);
|
||||||
|
pmode = va_arg(arg, int);
|
||||||
|
va_end(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return w32_wopen(file, oflag, pmode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
w32_wopen(const WCHAR *file, int oflag, int pmode)
|
||||||
{
|
{
|
||||||
char flags = 0;
|
char flags = 0;
|
||||||
int fd;
|
int fd;
|
||||||
@ -6032,11 +6028,6 @@ rb_w32_wopen(const WCHAR *file, int oflag, ...)
|
|||||||
share_delete = oflag & O_SHARE_DELETE ? FILE_SHARE_DELETE : 0;
|
share_delete = oflag & O_SHARE_DELETE ? FILE_SHARE_DELETE : 0;
|
||||||
oflag &= ~O_SHARE_DELETE;
|
oflag &= ~O_SHARE_DELETE;
|
||||||
if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
|
if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
|
||||||
va_list arg;
|
|
||||||
int pmode;
|
|
||||||
va_start(arg, oflag);
|
|
||||||
pmode = va_arg(arg, int);
|
|
||||||
va_end(arg);
|
|
||||||
fd = _wopen(file, oflag, pmode);
|
fd = _wopen(file, oflag, pmode);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
@ -6105,11 +6096,6 @@ rb_w32_wopen(const WCHAR *file, int oflag, ...)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (oflag & O_CREAT) {
|
if (oflag & O_CREAT) {
|
||||||
va_list arg;
|
|
||||||
int pmode;
|
|
||||||
va_start(arg, oflag);
|
|
||||||
pmode = va_arg(arg, int);
|
|
||||||
va_end(arg);
|
|
||||||
/* TODO: we need to check umask here, but it's not exported... */
|
/* TODO: we need to check umask here, but it's not exported... */
|
||||||
if (!(pmode & S_IWRITE))
|
if (!(pmode & S_IWRITE))
|
||||||
attr = FILE_ATTRIBUTE_READONLY;
|
attr = FILE_ATTRIBUTE_READONLY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user