Bug #8676 » win32_file_open_patch.patch
| include/ruby/intern.h (working copy) | ||
|---|---|---|
| #define rb_argv rb_get_argv() | ||
| RUBY_EXTERN VALUE rb_argv0; | ||
| VALUE rb_get_argv(void); | ||
| void *rb_load_file(const char*); | ||
| void *rb_load_file(VALUE); | ||
| /* signal.c */ | ||
| VALUE rb_f_kill(int, VALUE*); | ||
| #ifdef POSIX_SIGNAL | ||
| load.c (working copy) | ||
|---|---|---|
| 	VALUE iseq; | ||
| 	th->mild_compile_error++; | ||
| 	node = (NODE *)rb_load_file(RSTRING_PTR(fname)); | ||
| 	node = (NODE *)rb_load_file(fname); | ||
| 	loaded = TRUE; | ||
| 	iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); | ||
| 	th->mild_compile_error--; | ||
| ruby.c (working copy) | ||
|---|---|---|
| } | ||
| void * | ||
| rb_load_file(const char *fname) | ||
| rb_load_file(VALUE fname) | ||
| { | ||
|     struct cmdline_options opt; | ||
|     VALUE fname_v = rb_str_new_cstr(fname); | ||
|     return load_file(rb_parser_new(), fname_v, 0, cmdline_options_init(&opt)); | ||
|     return load_file(rb_parser_new(), fname, 0, cmdline_options_init(&opt)); | ||
| } | ||
| static void | ||
| win32/file.c (working copy) | ||
|---|---|---|
| rb_file_load_ok(const char *path) | ||
| { | ||
|     int ret = 1; | ||
|     DWORD attr = GetFileAttributes(path); | ||
|     size_t len; | ||
|     wchar_t* wpath; | ||
|     len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) + 1; | ||
|     wpath = (wchar_t *)xmalloc(len * sizeof(wchar_t)); | ||
|     MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, len); | ||
|     DWORD attr = GetFileAttributesW(wpath); | ||
|     if (attr == INVALID_FILE_ATTRIBUTES || | ||
| 	attr & FILE_ATTRIBUTE_DIRECTORY) { | ||
| 	ret = 0; | ||
|     } | ||
|     else { | ||
| 	HANDLE h = CreateFile(path, GENERIC_READ, | ||
| 	HANDLE h = CreateFileW(wpath, GENERIC_READ, | ||
| 			      FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 			      NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | ||
| 	if (h != INVALID_HANDLE_VALUE) { | ||
| ... | ... | |
| 	    ret = 0; | ||
| 	} | ||
|     } | ||
|     xfree(wpath); | ||
|     return ret; | ||
| } | ||