summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey McRae <geoff@spacevs.com>2011-11-10 23:06:53 +0000
committerGeoffrey McRae <geoff@spacevs.com>2011-11-10 23:06:53 +0000
commitd8bbb25fca01ddd95cbe6b390bf4a28b6b4a4d79 (patch)
tree71c5f5bec14bfbc5bb461851164dd2b6ae957373
parent46eb51eb068dd64ac7147f133939f0cbfa58dfd6 (diff)
Issue #15 - Fixed reading binary files under w32v0.2
-rw-r--r--parsers/binary.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/parsers/binary.c b/parsers/binary.c
index 6bb6a67..95e600e 100644
--- a/parsers/binary.c
+++ b/parsers/binary.c
@@ -41,7 +41,11 @@ parser_err_t binary_open(void *storage, const char *filename, const char write)
if (write) {
st->fd = open(
filename,
+#ifndef __WIN32__
O_WRONLY | O_CREAT | O_TRUNC,
+#else
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+#endif
#ifndef __WIN32__
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
#else
@@ -52,7 +56,14 @@ parser_err_t binary_open(void *storage, const char *filename, const char write)
} else {
if (stat(filename, &st->stat) != 0)
return PARSER_ERR_INVALID_FILE;
- st->fd = open(filename, O_RDONLY);
+ st->fd = open(
+ filename,
+#ifndef __WIN32__
+ O_RDONLY
+#else
+ O_RDONLY | O_BINARY
+#endif
+ );
}
st->write = write;