summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-05 01:50:06 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-05 01:50:06 +0000
commit525c8f80b28f38d2cc05fc745c41e27e9972e41f (patch)
tree71600e1c80ab130129ea46db52408a98cffc8cd7 /win32/win32.c
parent1d91fd6c4439d0224b06473e23eccadae3dae777 (diff)
* dir.c (dir_s_mkdir): win32 special processing doesn't need any
longer. (backported from CVS HEAD) * win32/win32.[ch] (rb_w32_mkdir): new function. POSIX.1 compatible interface. (backported from CVS HEAD) * win32/win32.[ch] (rb_w32_rmdir): new function. (backported from CVS HEAD) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 28eb4fc737..20d32d57c3 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3324,6 +3324,45 @@ rb_w32_snprintf(char *buf, size_t size, const char *format, ...)
return ret;
}
+#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;
+}
+
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
int
rb_w32_isatty(int fd)