<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,6 +5,15 @@
 #include &lt;lua.h&gt;
 #include &lt;lauxlib.h&gt;
 
+#ifndef O_BINARY
+  #ifdef _O_BINARY
+    #define O_BINARY _O_BINARY
+  #else
+    #define O_BINARY 0 // system doesn't need O_BINARY 
+  #endif
+#endif
+
+
 #include &quot;cdb.h&quot;
 
 #define LCDB_DB &quot;cdb.db&quot;
@@ -35,7 +44,7 @@ static int lcdb_open(lua_State *L) {
   const char *filename = luaL_checkstring(L, 1);
   int ret;
 
-  int fd = open(filename, O_RDONLY);
+  int fd = open(filename, O_RDONLY | O_BINARY);
   if (fd &lt; 0)
     return push_errno(L, errno);
 
@@ -166,7 +175,7 @@ static int lcdb_make(lua_State *L) {
   const char *dest = luaL_checkstring(L, 1);
   const char *tmpname = luaL_checkstring(L, 2);
 
-  fd = open(tmpname, O_RDWR|O_CREAT|O_EXCL, 0666);
+  fd = open(tmpname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666);
   if (fd &lt; 0)
     return push_errno(L, errno);
 </diff>
      <filename>lcdb.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>eb9b56079e6b5199c3f7a39ff06f1dccca3bd92c</id>
    </parent>
  </parents>
  <author>
    <name>A.S. Bradbury</name>
    <email>asb@asbradbury.org</email>
  </author>
  <url>http://github.com/asb/lua-tinycdb/commit/f5ea285cb29224af3d337df857036ce3750ac5e8</url>
  <id>f5ea285cb29224af3d337df857036ce3750ac5e8</id>
  <committed-date>2009-05-22T13:11:11-07:00</committed-date>
  <authored-date>2009-05-22T13:11:11-07:00</authored-date>
  <message>pass O_BINARY to open() to make Windows happy

Untested, but this should work. Previously, the file would have been opened in
ASCII mode on Windows which would corrupt the database.</message>
  <tree>85a8928a53341e52ec7e147e598ca3a82884ac59</tree>
  <committer>
    <name>A.S. Bradbury</name>
    <email>asb@asbradbury.org</email>
  </committer>
</commit>
