1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05: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:
usa 2004-12-07 04:45:46 +00:00
parent 69b64a7d5f
commit 571e1361b6
4 changed files with 55 additions and 5 deletions

View file

@ -1,3 +1,12 @@
Tue Dec 7 13:42:07 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* 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.
Tue Dec 7 00:27:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (proc_setgroups): [ruby-dev:25081]

5
dir.c
View file

@ -895,13 +895,8 @@ dir_s_mkdir(argc, argv, obj)
}
check_dirname(&path);
#ifndef _WIN32
if (mkdir(RSTRING(path)->ptr, mode) == -1)
rb_sys_fail(RSTRING(path)->ptr);
#else
if (mkdir(RSTRING(path)->ptr) == -1)
rb_sys_fail(RSTRING(path)->ptr);
#endif
return INT2FIX(0);
}

View file

@ -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
//

View file

@ -130,6 +130,11 @@ extern "C++" {
#undef isatty
#define isatty(h) rb_w32_isatty(h)
#undef mkdir
#define mkdir(p, m) rb_w32_mkdir(p, m)
#undef rmdir
#define rmdir(p) rb_w32_rmdir(p)
#ifdef __MINGW32__
struct timezone {
int tz_minuteswest;
@ -190,6 +195,8 @@ extern int kill(int, int);
extern int fcntl(int, int, ...);
extern pid_t rb_w32_getpid(void);
extern int rb_w32_isatty(int);
extern int rb_w32_mkdir(const char *, int);
extern int rb_w32_rmdir(const char *);
#ifdef __BORLANDC__
extern int rb_w32_fstat(int, struct stat *);