From 36343cf098e2621696a9ae4ad35e7104f5f6383e Mon Sep 17 00:00:00 2001 From: Jared Breeden Date: Fri, 17 Apr 2015 15:39:11 -0400 Subject: Correct File::NULL for Windows --- mrblib/file_constants.rb | 2 -- src/file.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mrblib/file_constants.rb b/mrblib/file_constants.rb index c2552bf56..a68ee2598 100644 --- a/mrblib/file_constants.rb +++ b/mrblib/file_constants.rb @@ -1,7 +1,5 @@ class File module Constants - NULL = "/dev/null" - RDONLY = 0 WRONLY = 1 RDWR = 2 diff --git a/src/file.c b/src/file.c index c2419c2cc..b6a3c90c7 100644 --- a/src/file.c +++ b/src/file.c @@ -311,4 +311,9 @@ mrb_init_file(mrb_state *mrb) mrb_define_const(mrb, cnst, "LOCK_UN", mrb_fixnum_value(LOCK_UN)); mrb_define_const(mrb, cnst, "LOCK_NB", mrb_fixnum_value(LOCK_NB)); mrb_define_const(mrb, cnst, "SEPARATOR", mrb_str_new_cstr(mrb, FILE_SEPARATOR)); +#if defined(_WIN32) || defined(_WIN64) + mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, "NUL")); +#else + mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, "/dev/null")); +#endif } -- cgit v1.2.3 From 6d6be18d4eadb6a644c4ea7319b336a5a6fdf52b Mon Sep 17 00:00:00 2001 From: Jared Breeden Date: Fri, 17 Apr 2015 15:45:14 -0400 Subject: Removing redundant platform check --- src/file.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/file.c b/src/file.c index b6a3c90c7..873c3454f 100644 --- a/src/file.c +++ b/src/file.c @@ -24,6 +24,7 @@ #include #include #if defined(_WIN32) || defined(_WIN64) + #define NULL_FILE "NUL" #define UNLINK _unlink #define GETCWD _getcwd #define CHMOD(a, b) 0 @@ -34,6 +35,7 @@ #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) #include #else + #define NULL_FILE "/dev/null" #include #define UNLINK unlink #define GETCWD getcwd @@ -311,9 +313,5 @@ mrb_init_file(mrb_state *mrb) mrb_define_const(mrb, cnst, "LOCK_UN", mrb_fixnum_value(LOCK_UN)); mrb_define_const(mrb, cnst, "LOCK_NB", mrb_fixnum_value(LOCK_NB)); mrb_define_const(mrb, cnst, "SEPARATOR", mrb_str_new_cstr(mrb, FILE_SEPARATOR)); -#if defined(_WIN32) || defined(_WIN64) - mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, "NUL")); -#else - mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, "/dev/null")); -#endif + mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, NULL_FILE)); } -- cgit v1.2.3