Kouhei Sutou
null+****@clear*****
Fri May 19 14:02:25 JST 2017
Kouhei Sutou 2017-05-19 14:02:25 +0900 (Fri, 19 May 2017) New Revision: 248731bd67aab126266cd19fbe9626408fc8a821 https://github.com/groonga/groonga/commit/248731bd67aab126266cd19fbe9626408fc8a821 Message: windows io: ensure reading IO version O_CREAT means that "if the file doesn't exist, it's created. If the file exists, it's opened.". So the file may have content even when the file is opened with O_CREAT. Modified files: lib/io.c Modified: lib/io.c (+4 -3) =================================================================== --- lib/io.c 2017-05-19 14:01:49 +0900 (0809fb1) +++ lib/io.c 2017-05-19 14:02:25 +0900 (1bf60ff) @@ -1745,8 +1745,7 @@ grn_fileinfo_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags) { grn_rc rc; struct _grn_io_header io_header; - DWORD header_size; - DWORD read_bytes; + LARGE_INTEGER file_size; int version = grn_io_version_default; rc = grn_fileinfo_open_common(ctx, fi, path, flags); @@ -1754,7 +1753,9 @@ grn_fileinfo_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags) return rc; } - if (!(flags & O_CREAT)) { + if (GetFileSizeEx(fi->fh, &file_size) && file_size.QuadPart > 0) { + DWORD header_size; + DWORD read_bytes; header_size = sizeof(struct _grn_io_header); ReadFile(fi->fh, &io_header, header_size, &read_bytes, NULL); if (read_bytes == header_size) { -------------- next part -------------- HTML����������������������������...Download