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
e7e99941
Unverified
Commit
e7e99941
authored
Jan 28, 2020
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jan 28, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4873 from dearblue/open-flags
Support bit flags for `IO.open`
parents
364c4761
69619aee
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
151 additions
and
88 deletions
+151
-88
mrbgems/mruby-io/include/mruby/ext/io.h
mrbgems/mruby-io/include/mruby/ext/io.h
+25
-7
mrbgems/mruby-io/mrblib/file_constants.rb
mrbgems/mruby-io/mrblib/file_constants.rb
+0
-16
mrbgems/mruby-io/src/file.c
mrbgems/mruby-io/src/file.c
+18
-0
mrbgems/mruby-io/src/io.c
mrbgems/mruby-io/src/io.c
+108
-65
No files found.
mrbgems/mruby-io/include/mruby/ext/io.h
View file @
e7e99941
...
...
@@ -19,13 +19,31 @@ struct mrb_io {
is_socket:
1
;
};
#define FMODE_READABLE 0x00000001
#define FMODE_WRITABLE 0x00000002
#define FMODE_READWRITE (FMODE_READABLE|FMODE_WRITABLE)
#define FMODE_BINMODE 0x00000004
#define FMODE_APPEND 0x00000040
#define FMODE_CREATE 0x00000080
#define FMODE_TRUNC 0x00000800
#define MRB_O_RDONLY 0x0000
#define MRB_O_WRONLY 0x0001
#define MRB_O_RDWR 0x0002
#define MRB_O_ACCMODE (MRB_O_RDONLY | MRB_O_WRONLY | MRB_O_RDWR)
#define MRB_O_NONBLOCK 0x0004
#define MRB_O_APPEND 0x0008
#define MRB_O_SYNC 0x0010
#define MRB_O_NOFOLLOW 0x0020
#define MRB_O_CREAT 0x0040
#define MRB_O_TRUNC 0x0080
#define MRB_O_EXCL 0x0100
#define MRB_O_NOCTTY 0x0200
#define MRB_O_DIRECT 0x0400
#define MRB_O_BINARY 0x0800
#define MRB_O_SHARE_DELETE 0x1000
#define MRB_O_TMPFILE 0x2000
#define MRB_O_NOATIME 0x4000
#define MRB_O_DSYNC 0x00008000
/* Ignored with MRB_INT16 and MRB_WITHOUT_FLOAT */
#define MRB_O_RSYNC 0x00010000
/* Ignored with MRB_INT16 and MRB_WITHOUT_FLOAT */
#define MRB_O_RDONLY_P(f) ((mrb_bool)(((f) & MRB_O_ACCMODE) == MRB_O_RDONLY))
#define MRB_O_WRONLY_P(f) ((mrb_bool)(((f) & MRB_O_ACCMODE) == MRB_O_WRONLY))
#define MRB_O_RDWR_P(f) ((mrb_bool)(((f) & MRB_O_ACCMODE) == MRB_O_RDWR))
#define MRB_O_READABLE_P(f) ((mrb_bool)((((f) & MRB_O_ACCMODE) | 2) == 2))
#define MRB_O_WRITABLE_P(f) ((mrb_bool)(((((f) & MRB_O_ACCMODE) + 1) & 2) == 2))
#define E_IO_ERROR (mrb_class_get(mrb, "IOError"))
#define E_EOF_ERROR (mrb_class_get(mrb, "EOFError"))
...
...
mrbgems/mruby-io/mrblib/file_constants.rb
View file @
e7e99941
class
File
module
Constants
RDONLY
=
0
WRONLY
=
1
RDWR
=
2
NONBLOCK
=
4
APPEND
=
8
BINARY
=
0
SYNC
=
128
NOFOLLOW
=
256
CREAT
=
512
TRUNC
=
1024
EXCL
=
2048
NOCTTY
=
131072
DSYNC
=
4194304
FNM_SYSCASE
=
0
FNM_NOESCAPE
=
1
FNM_PATHNAME
=
2
...
...
mrbgems/mruby-io/src/file.c
View file @
e7e99941
...
...
@@ -599,4 +599,22 @@ mrb_init_file(mrb_state *mrb)
#endif
mrb_define_const
(
mrb
,
cnst
,
"NULL"
,
mrb_str_new_cstr
(
mrb
,
NULL_FILE
));
mrb_define_const
(
mrb
,
cnst
,
"RDONLY"
,
mrb_fixnum_value
(
MRB_O_RDONLY
));
mrb_define_const
(
mrb
,
cnst
,
"WRONLY"
,
mrb_fixnum_value
(
MRB_O_WRONLY
));
mrb_define_const
(
mrb
,
cnst
,
"RDWR"
,
mrb_fixnum_value
(
MRB_O_RDWR
));
mrb_define_const
(
mrb
,
cnst
,
"APPEND"
,
mrb_fixnum_value
(
MRB_O_APPEND
));
mrb_define_const
(
mrb
,
cnst
,
"CREAT"
,
mrb_fixnum_value
(
MRB_O_CREAT
));
mrb_define_const
(
mrb
,
cnst
,
"EXCL"
,
mrb_fixnum_value
(
MRB_O_EXCL
));
mrb_define_const
(
mrb
,
cnst
,
"TRUNC"
,
mrb_fixnum_value
(
MRB_O_TRUNC
));
mrb_define_const
(
mrb
,
cnst
,
"NONBLOCK"
,
mrb_fixnum_value
(
MRB_O_NONBLOCK
));
mrb_define_const
(
mrb
,
cnst
,
"NOCTTY"
,
mrb_fixnum_value
(
MRB_O_NOCTTY
));
mrb_define_const
(
mrb
,
cnst
,
"BINARY"
,
mrb_fixnum_value
(
MRB_O_BINARY
));
mrb_define_const
(
mrb
,
cnst
,
"SHARE_DELETE"
,
mrb_fixnum_value
(
MRB_O_SHARE_DELETE
));
mrb_define_const
(
mrb
,
cnst
,
"SYNC"
,
mrb_fixnum_value
(
MRB_O_SYNC
));
mrb_define_const
(
mrb
,
cnst
,
"DSYNC"
,
mrb_fixnum_value
(
MRB_O_DSYNC
));
mrb_define_const
(
mrb
,
cnst
,
"RSYNC"
,
mrb_fixnum_value
(
MRB_O_RSYNC
));
mrb_define_const
(
mrb
,
cnst
,
"NOFOLLOW"
,
mrb_fixnum_value
(
MRB_O_NOFOLLOW
));
mrb_define_const
(
mrb
,
cnst
,
"NOATIME"
,
mrb_fixnum_value
(
MRB_O_NOATIME
));
mrb_define_const
(
mrb
,
cnst
,
"DIRECT"
,
mrb_fixnum_value
(
MRB_O_DIRECT
));
mrb_define_const
(
mrb
,
cnst
,
"TMPFILE"
,
mrb_fixnum_value
(
MRB_O_TMPFILE
));
}
mrbgems/mruby-io/src/io.c
View file @
e7e99941
This diff is collapsed.
Click to expand it.
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