|
1
|
Index: include/ruby/intern.h
|
|
2
|
===================================================================
|
|
3
|
--- include/ruby/intern.h (revision 26984)
|
|
4
|
+++ include/ruby/intern.h (working copy)
|
|
5
|
@@ -838,6 +838,10 @@
|
|
6
|
void rb_frame_pop(void);
|
|
7
|
int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
|
|
8
|
|
|
9
|
+#ifdef _WIN32
|
|
10
|
+int w32_conv_to_utf16(volatile VALUE *strp);
|
|
11
|
+#endif
|
|
12
|
+
|
|
13
|
#if defined(__cplusplus)
|
|
14
|
#if 0
|
|
15
|
{ /* satisfy cc-mode */
|
|
16
|
Index: include/ruby/win32.h
|
|
17
|
===================================================================
|
|
18
|
--- include/ruby/win32.h (revision 26984)
|
|
19
|
+++ include/ruby/win32.h (working copy)
|
|
20
|
@@ -274,6 +274,7 @@
|
|
21
|
extern int rb_w32_isatty(int);
|
|
22
|
#endif
|
|
23
|
extern int rb_w32_mkdir(const char *, int);
|
|
24
|
+extern int rb_w32_wmkdir(const WCHAR *, int);
|
|
25
|
extern int rb_w32_rmdir(const char *);
|
|
26
|
extern int rb_w32_unlink(const char *);
|
|
27
|
extern int rb_w32_stati64(const char *, struct stati64 *);
|
|
28
|
Index: io.c
|
|
29
|
===================================================================
|
|
30
|
--- io.c (revision 26984)
|
|
31
|
+++ io.c (working copy)
|
|
32
|
@@ -4411,35 +4411,6 @@
|
|
33
|
#endif
|
|
34
|
};
|
|
35
|
|
|
36
|
-#ifdef _WIN32
|
|
37
|
-static rb_encoding *
|
|
38
|
-w32_utf16(void)
|
|
39
|
-{
|
|
40
|
- static rb_encoding *utf16 = (rb_encoding *)-1;
|
|
41
|
- if (utf16 == (rb_encoding *)-1) {
|
|
42
|
- utf16 = rb_enc_find("UTF-16LE");
|
|
43
|
- if (utf16 == rb_ascii8bit_encoding())
|
|
44
|
- utf16 = NULL;
|
|
45
|
- }
|
|
46
|
- return utf16;
|
|
47
|
-}
|
|
48
|
-
|
|
49
|
-static int
|
|
50
|
-w32_conv_to_utf16(volatile VALUE *strp)
|
|
51
|
-{
|
|
52
|
- rb_encoding *utf16 = w32_utf16();
|
|
53
|
- if (utf16) {
|
|
54
|
- VALUE wstr = rb_str_encode(*strp, rb_enc_from_encoding(utf16), 0, Qnil);
|
|
55
|
- rb_enc_str_buf_cat(wstr, "", 1, utf16); /* workaround */
|
|
56
|
- *strp = wstr;
|
|
57
|
- return 1;
|
|
58
|
- }
|
|
59
|
- else {
|
|
60
|
- return 0;
|
|
61
|
- }
|
|
62
|
-}
|
|
63
|
-#endif
|
|
64
|
-
|
|
65
|
static VALUE
|
|
66
|
sysopen_func(void *ptr)
|
|
67
|
{
|
|
68
|
Index: dir.c
|
|
69
|
===================================================================
|
|
70
|
--- dir.c (revision 26984)
|
|
71
|
+++ dir.c (working copy)
|
|
72
|
@@ -937,6 +937,9 @@
|
|
73
|
dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
|
|
74
|
{
|
|
75
|
VALUE path, vmode;
|
|
76
|
+#ifdef _WIN32
|
|
77
|
+ VALUE wpath;
|
|
78
|
+#endif
|
|
79
|
int mode;
|
|
80
|
|
|
81
|
if (rb_scan_args(argc, argv, "11", &path, &vmode) == 2) {
|
|
82
|
@@ -947,6 +950,15 @@
|
|
83
|
}
|
|
84
|
|
|
85
|
check_dirname(&path);
|
|
86
|
+#ifdef _WIN32
|
|
87
|
+ wpath = path;
|
|
88
|
+ if (w32_conv_to_utf16(&wpath) != 0) {
|
|
89
|
+ OBJ_FREEZE(wpath);
|
|
90
|
+ if (rb_w32_wmkdir((WCHAR *)RSTRING_PTR(wpath), mode) == -1)
|
|
91
|
+ rb_sys_fail(RSTRING_PTR(path));
|
|
92
|
+ }
|
|
93
|
+ else
|
|
94
|
+#endif
|
|
95
|
if (mkdir(RSTRING_PTR(path), mode) == -1)
|
|
96
|
rb_sys_fail(RSTRING_PTR(path));
|
|
97
|
|
|
98
|
Index: win32/win32.c
|
|
99
|
===================================================================
|
|
100
|
--- win32/win32.c (revision 26984)
|
|
101
|
+++ win32/win32.c (working copy)
|
|
102
|
@@ -5162,6 +5162,24 @@
|
|
103
|
}
|
|
104
|
|
|
105
|
int
|
|
106
|
+rb_w32_wmkdir(const WCHAR *wpath, int mode)
|
|
107
|
+{
|
|
108
|
+ int ret = -1;
|
|
109
|
+ RUBY_CRITICAL(do {
|
|
110
|
+ if (CreateDirectoryW(wpath, NULL) == FALSE) {
|
|
111
|
+ errno = map_errno(GetLastError());
|
|
112
|
+ break;
|
|
113
|
+ }
|
|
114
|
+ if (_wchmod(wpath, mode) == -1) {
|
|
115
|
+ RemoveDirectoryW(wpath);
|
|
116
|
+ break;
|
|
117
|
+ }
|
|
118
|
+ ret = 0;
|
|
119
|
+ } while (0));
|
|
120
|
+ return ret;
|
|
121
|
+}
|
|
122
|
+
|
|
123
|
+int
|
|
124
|
rb_w32_rmdir(const char *path)
|
|
125
|
{
|
|
126
|
int ret = 0;
|
|
127
|
@@ -5291,3 +5309,31 @@
|
|
128
|
return *ip < 0;
|
|
129
|
}
|
|
130
|
#endif
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+static rb_encoding *
|
|
134
|
+w32_utf16(void)
|
|
135
|
+{
|
|
136
|
+ static rb_encoding *utf16 = (rb_encoding *)-1;
|
|
137
|
+ if (utf16 == (rb_encoding *)-1) {
|
|
138
|
+ utf16 = rb_enc_find("UTF-16LE");
|
|
139
|
+ if (utf16 == rb_ascii8bit_encoding())
|
|
140
|
+ utf16 = NULL;
|
|
141
|
+ }
|
|
142
|
+ return utf16;
|
|
143
|
+}
|
|
144
|
+
|
|
145
|
+int
|
|
146
|
+w32_conv_to_utf16(volatile VALUE *strp)
|
|
147
|
+{
|
|
148
|
+ rb_encoding *utf16 = w32_utf16();
|
|
149
|
+ if (utf16) {
|
|
150
|
+ VALUE wstr = rb_str_encode(*strp, rb_enc_from_encoding(utf16), 0, Qnil);
|
|
151
|
+ rb_enc_str_buf_cat(wstr, "", 1, utf16); /* workaround */
|
|
152
|
+ *strp = wstr;
|
|
153
|
+ return 1;
|
|
154
|
+ }
|
|
155
|
+ else {
|
|
156
|
+ return 0;
|
|
157
|
+ }
|
|
158
|
+}
|
|
159
|
|