Navigation Menu

Skip to content

Commit

Permalink
windows io: detect version only when opening existing file
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 17, 2015
1 parent bb29092 commit c1542ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/io.c
Expand Up @@ -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);
Expand Down

0 comments on commit c1542ac

Please sign in to comment.