[Groonga-commit] groonga/groonga at c1542ac [master] windows io: detect version only when opening existing file

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Jan 17 17:33:22 JST 2015


Kouhei Sutou	2015-01-17 17:33:22 +0900 (Sat, 17 Jan 2015)

  New Revision: c1542ac22843fbfaf4dd81bbbd14b13c250c60b3
  https://github.com/groonga/groonga/commit/c1542ac22843fbfaf4dd81bbbd14b13c250c60b3

  Message:
    windows io: detect version only when opening existing file

  Modified files:
    lib/io.c

  Modified: lib/io.c (+7 -5)
===================================================================
--- lib/io.c    2015-01-17 17:26:36 +0900 (ea009e6)
+++ lib/io.c    2015-01-17 17:33:22 +0900 (d931d50)
@@ -1529,12 +1529,14 @@ grn_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags)
     return rc;
   }
 
-  header_size = sizeof(struct _grn_io_header);
-  ReadFile(fi->fh, &io_header, header_size, &read_bytes, NULL);
-  if (read_bytes == header_size) {
-    version = io_header.version;
+  if (!(flags & O_CREAT)) {
+    header_size = sizeof(struct _grn_io_header);
+    ReadFile(fi->fh, &io_header, header_size, &read_bytes, NULL);
+    if (read_bytes == header_size) {
+      version = io_header.version;
+    }
+    SetFilePointer(fi->fh, 0, NULL, FILE_BEGIN);
   }
-  SetFilePointer(fi->fh, 0, NULL, FILE_BEGIN);
 
   if (version == 0) {
     return grn_open_v0(ctx, fi, path, flags);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index