Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
5a59fd3a
Commit
5a59fd3a
authored
Dec 02, 2013
by
Paolo Bosetti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for compilation under Win/MinGW
parent
87d87829
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
4 deletions
+26
-4
include/mruby/ext/io.h
include/mruby/ext/io.h
+5
-1
src/file.c
src/file.c
+12
-1
src/file_test.c
src/file_test.c
+2
-0
src/io.c
src/io.c
+7
-2
No files found.
include/mruby/ext/io.h
View file @
5a59fd3a
...
...
@@ -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>
...
...
src/file.c
View file @
5a59fd3a
...
...
@@ -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
));
...
...
src/file_test.c
View file @
5a59fd3a
...
...
@@ -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
;
...
...
src/io.c
View file @
5a59fd3a
...
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment