Project

General

Profile

Feature #11218 » share_delete.patch

usa (Usaku NAKAMURA), 06/04/2015 10:42 AM

View differences:

include/ruby/win32.h (??ƃR?s?[)
124 124

  
125 125
#define WNOHANG -1
126 126

  
127
#define O_DELETE 0x80000000 /* for rb_w32_open(), rb_w32_wopen() */
128

  
127 129
typedef int clockid_t;
128 130
#define CLOCK_REALTIME  0
129 131
#define CLOCK_MONOTONIC 1
io.c (??ƃR?s?[)
175 175
static ID id_write, id_read, id_getc, id_flush, id_readpartial, id_set_encoding;
176 176
static VALUE sym_mode, sym_perm, sym_extenc, sym_intenc, sym_encoding, sym_open_args;
177 177
static VALUE sym_textmode, sym_binmode, sym_autoclose;
178
#ifdef O_DELETE
179
static VALUE sym_share_delete;
180
#endif
178 181
static VALUE sym_SET, sym_CUR, sym_END;
179 182
#ifdef SEEK_DATA
180 183
static VALUE sym_DATA;
......
5383 5386
		/* perm no use, just ignore */
5384 5387
	    }
5385 5388
	}
5389
#ifdef O_DELETE
5390
	v = rb_hash_aref(opthash, sym_share_delete);
5391
	if (!NIL_P(v)) oflags |= O_DELETE;
5392
#endif
5386 5393
	ecflags = (fmode & FMODE_READABLE) ?
5387 5394
	    MODE_BTMODE(ECONV_DEFAULT_NEWLINE_DECORATOR,
5388 5395
			0, ECONV_UNIVERSAL_NEWLINE_DECORATOR) : 0;
......
12430 12437
    sym_textmode = ID2SYM(rb_intern("textmode"));
12431 12438
    sym_binmode = ID2SYM(rb_intern("binmode"));
12432 12439
    sym_autoclose = ID2SYM(rb_intern("autoclose"));
12440
#ifdef O_DELETE
12441
    sym_share_delete = ID2SYM(rb_intern("share_delete"));
12442
#endif
12433 12443
    sym_normal = ID2SYM(rb_intern("normal"));
12434 12444
    sym_sequential = ID2SYM(rb_intern("sequential"));
12435 12445
    sym_random = ID2SYM(rb_intern("random"));
win32/win32.c (??ƃR?s?[)
5775 5775
    va_end(arg);
5776 5776

  
5777 5777
    if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
5778
	oflag &= ~O_DELETE;
5778 5779
	ret = _open(file, oflag, pmode);
5779 5780
	if (ret == -1 && errno == EACCES) check_if_dir(file);
5780 5781
	return ret;
......
5797 5798
    DWORD attr = FILE_ATTRIBUTE_NORMAL;
5798 5799
    SECURITY_ATTRIBUTES sec;
5799 5800
    HANDLE h;
5801
    int delete;
5800 5802

  
5803
    delete = oflag & O_DELETE;
5804
    oflag &= ~O_DELETE;
5801 5805
    if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
5802 5806
	va_list arg;
5803 5807
	int pmode;
......
5919 5923
	_set_osfhnd(fd, (intptr_t)INVALID_HANDLE_VALUE);
5920 5924
	_set_osflags(fd, 0);
5921 5925

  
5922
	h = CreateFileW(file, access, FILE_SHARE_READ | FILE_SHARE_WRITE, &sec,
5923
			create, attr, NULL);
5926
	h = CreateFileW(file, access, FILE_SHARE_READ | FILE_SHARE_WRITE | (delete ? FILE_SHARE_DELETE : 0), &sec, create, attr, NULL);
5924 5927
	if (h == INVALID_HANDLE_VALUE) {
5925 5928
	    DWORD e = GetLastError();
5926 5929
	    if (e != ERROR_ACCESS_DENIED || !check_if_wdir(file))