summaryrefslogtreecommitdiff
path: root/win32/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/file.c')
-rw-r--r--win32/file.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/win32/file.c b/win32/file.c
index 6452aad..92b99a0 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -1,5 +1,6 @@
#include "ruby/ruby.h"
#include "ruby/encoding.h"
+#include "ruby/thread.h"
#include "internal.h"
#include <winbase.h>
#include <wchar.h>
@@ -683,6 +684,14 @@ rb_readlink(VALUE path)
return append_wstr(rb_enc_str_new(0, 0, enc), wbuf, len, cp, path_cp, enc);
}
+static void *
+loadopen_func(void *wpath)
+{
+ return (void *)CreateFileW(wpath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+}
+
int
rb_file_load_ok(const char *path)
{
@@ -700,9 +709,8 @@ rb_file_load_ok(const char *path)
ret = 0;
}
else {
- HANDLE h = CreateFileW(wpath, GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE h = (HANDLE)rb_thread_call_without_gvl(loadopen_func, (void *)wpath,
+ RUBY_UBF_IO, 0);
if (h != INVALID_HANDLE_VALUE) {
CloseHandle(h);
}