зеркало из https://github.com/github/ruby.git
* io.c (rb_io_flags_mode, rb_io_mode_flags): distinguish whether file
not existing is created. [ruby-dev:24505] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6a6773b969
Коммит
0fdb2ae104
|
@ -1,3 +1,8 @@
|
|||
Mon Oct 18 11:29:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (rb_io_flags_mode, rb_io_mode_flags): distinguish whether file
|
||||
not existing is created. [ruby-dev:24505]
|
||||
|
||||
Mon Oct 18 07:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_truncate): discard read buffer before truncation.
|
||||
|
|
7
io.c
7
io.c
|
@ -2304,6 +2304,9 @@ rb_io_flags_mode(flags)
|
|||
case FMODE_WRITABLE:
|
||||
return MODE_BINMODE("w", "wb");
|
||||
case FMODE_READWRITE:
|
||||
if (flags & FMODE_CREATE) {
|
||||
return MODE_BINMODE("w+", "wb+");
|
||||
}
|
||||
return MODE_BINMODE("r+", "rb+");
|
||||
}
|
||||
rb_raise(rb_eArgError, "illegal access mode %o", flags);
|
||||
|
@ -2322,10 +2325,10 @@ rb_io_mode_flags(mode)
|
|||
flags |= FMODE_READABLE;
|
||||
break;
|
||||
case 'w':
|
||||
flags |= FMODE_WRITABLE;
|
||||
flags |= FMODE_WRITABLE | FMODE_CREATE;
|
||||
break;
|
||||
case 'a':
|
||||
flags |= FMODE_WRITABLE | FMODE_APPEND;
|
||||
flags |= FMODE_WRITABLE | FMODE_APPEND | FMODE_CREATE;
|
||||
break;
|
||||
default:
|
||||
error:
|
||||
|
|
1
rubyio.h
1
rubyio.h
|
@ -31,6 +31,7 @@ typedef struct OpenFile {
|
|||
#define FMODE_WRITABLE 2
|
||||
#define FMODE_READWRITE 3
|
||||
#define FMODE_APPEND 64
|
||||
#define FMODE_CREATE 128
|
||||
#define FMODE_BINMODE 4
|
||||
#define FMODE_SYNC 8
|
||||
#define FMODE_WBUF 16
|
||||
|
|
Загрузка…
Ссылка в новой задаче