mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
* io.c (dir_s_mkdir): win32 special processing doesn't need any longer.
* win32/win32.[ch] (rb_w32_mkdir): new function. POSIX.1 compatible interface. * win32/win32.[ch] (rb_w32_rmdir): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69b64a7d5f
commit
571e1361b6
4 changed files with 55 additions and 5 deletions
|
@ -3430,6 +3430,45 @@ rb_w32_isatty(int fd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#undef mkdir
|
||||
#undef rmdir
|
||||
int
|
||||
rb_w32_mkdir(const char *path, int mode)
|
||||
{
|
||||
int ret = -1;
|
||||
RUBY_CRITICAL(do {
|
||||
if (mkdir(path) == -1)
|
||||
break;
|
||||
if (chmod(path, mode) == -1) {
|
||||
int save_errno = errno;
|
||||
rmdir(path);
|
||||
errno = save_errno;
|
||||
break;
|
||||
}
|
||||
ret = 0;
|
||||
} while (0));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
rb_w32_rmdir(const char *path)
|
||||
{
|
||||
DWORD attr;
|
||||
int ret;
|
||||
RUBY_CRITICAL({
|
||||
attr = GetFileAttributes(path);
|
||||
if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) {
|
||||
attr &= ~FILE_ATTRIBUTE_READONLY;
|
||||
SetFileAttributes(path, attr);
|
||||
}
|
||||
ret = rmdir(path);
|
||||
if (ret < 0 && attr != (DWORD)-1) {
|
||||
SetFileAttributes(path, attr);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// Fix bcc32's stdio bug
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue