Commit 5a59fd3a authored by Paolo Bosetti's avatar Paolo Bosetti

Fix for compilation under Win/MinGW

parent 87d87829
......@@ -16,7 +16,11 @@ extern "C" {
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#if !defined(_WIN32) || !defined(__MINGW32__)
#include <sys/wait.h>
#else
#include <winsock.h>
#endif
#include <stdio.h>
#include <string.h>
#include <limits.h>
......
......@@ -17,7 +17,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#ifndef _WIN32
#include <pwd.h>
#endif
#define FILE_SEPARATOR "/"
......@@ -229,6 +231,7 @@ mrb_file_is_absolute_path(const char *path)
static mrb_value
mrb_file__gethome(mrb_state *mrb, mrb_value klass)
{
#ifndef _WIN32
mrb_value username;
int argc;
char *home;
......@@ -254,8 +257,13 @@ mrb_file__gethome(mrb_state *mrb, mrb_value klass)
}
}
return mrb_str_new_cstr(mrb, home);
#else
return mrb_nil_value();
#endif
}
#ifndef _WIN32
mrb_value
mrb_file_flock(mrb_state *mrb, mrb_value self)
{
......@@ -285,6 +293,7 @@ mrb_file_flock(mrb_state *mrb, mrb_value self)
}
return mrb_fixnum_value(0);
}
#endif
void
mrb_init_file(mrb_state *mrb)
......@@ -306,8 +315,10 @@ mrb_init_file(mrb_state *mrb)
mrb_define_class_method(mrb, file, "_getwd", mrb_file__getwd, MRB_ARGS_NONE());
mrb_define_class_method(mrb, file, "_gethome", mrb_file__gethome, MRB_ARGS_OPT(1));
#ifndef _WIN32
mrb_define_method(mrb, file, "flock", mrb_file_flock, MRB_ARGS_REQ(1));
#endif
cnst = mrb_define_module_under(mrb, file, "Constants");
mrb_define_const(mrb, cnst, "LOCK_SH", mrb_fixnum_value(LOCK_SH));
mrb_define_const(mrb, cnst, "LOCK_EX", mrb_fixnum_value(LOCK_EX));
......
......@@ -16,7 +16,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#ifndef _WIN32
#include <pwd.h>
#endif
extern struct mrb_data_type mrb_io_type;
......
......@@ -119,13 +119,14 @@ mrb_io_flags_to_modenum(mrb_state *mrb, int flags)
}
#ifdef O_BINARY
if (flags & FMODE_BINMODE) {
modenum |= O_BINARY
modenum |= O_BINARY;
}
#endif
return modenum;
}
#ifndef _WIN32
static int
mrb_proc_exec(const char *pname)
{
......@@ -143,6 +144,7 @@ mrb_proc_exec(const char *pname)
execl("/bin/sh", "sh", "-c", pname, (char *)NULL);
return -1;
}
#endif
static void
mrb_io_free(mrb_state *mrb, void *ptr)
......@@ -185,6 +187,7 @@ io_open(mrb_state *mrb, mrb_value path, int flags, int perm)
#define NOFILE 64
#endif
#ifndef _WIN32
mrb_value
mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
{
......@@ -295,6 +298,7 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
}
return result;
}
#endif
mrb_value
mrb_io_initialize(mrb_state *mrb, mrb_value io)
......@@ -746,8 +750,9 @@ mrb_init_io(mrb_state *mrb)
MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);
mrb_include_module(mrb, io, mrb_class_get(mrb, "Enumerable")); /* 15.2.20.3 */
#ifndef _WIN32
mrb_define_class_method(mrb, io, "_popen", mrb_io_s_popen, MRB_ARGS_ANY());
#endif
mrb_define_class_method(mrb, io, "for_fd", mrb_io_s_for_fd, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(2));
mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, MRB_ARGS_ANY());
mrb_define_class_method(mrb, io, "select", mrb_io_s_select, MRB_ARGS_ANY());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment