From 96ab5e1bb8ab6a4fdb9649a575985566539613e4 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Mon, 5 Nov 2012 19:05:35 +0900 Subject: [PATCH] windows: fix a bug that over 128MB column value can't be read [groonga-dev,01088] Reported by ongaeshi. Thanks!!! --- lib/io.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/io.c b/lib/io.c index ba3ef6b665..4200a83143 100644 --- a/lib/io.c +++ b/lib/io.c @@ -1526,9 +1526,15 @@ inline static grn_rc grn_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags, size_t maxsize) { if ((flags & O_CREAT)) { + DWORD dwCreationDisposition; + if (flags & O_EXCL) { + dwCreationDisposition = CREATE_NEW; + } else { + dwCreationDisposition = OPEN_ALWAYS; + } fi->fh = CreateFile(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, 0); if (fi->fh == INVALID_HANDLE_VALUE) { SERR("CreateFile"); return ctx->rc; @@ -1629,9 +1635,15 @@ grn_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags, size_t maxsize { /* may be wrong if flags is just only O_RDWR */ if ((flags & O_CREAT)) { + DWORD dwCreationDisposition; + if (flags & O_EXCL) { + dwCreationDisposition = CREATE_NEW; + } else { + dwCreationDisposition = OPEN_ALWAYS; + } fi->fh = CreateFile(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, 0); if (fi->fh == INVALID_HANDLE_VALUE) { SERR("CreateFile"); return ctx->rc;