Skip to content

Commit

Permalink
Support 'rs' and 'rs+' for flags in fs.open()
Browse files Browse the repository at this point in the history
  • Loading branch information
hnakamur committed Aug 12, 2012
1 parent e6afd7c commit 2b2e21e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/luv_fs.c
Expand Up @@ -83,6 +83,8 @@ int luv_string_to_flags(lua_State* L, const char* string) {
if (strcmp(string, "w+") == 0) return O_CREAT | O_TRUNC | O_RDWR;
if (strcmp(string, "a") == 0) return O_APPEND | O_CREAT | O_WRONLY;
if (strcmp(string, "a+") == 0) return O_APPEND | O_CREAT | O_RDWR;
if (strcmp(string, "rs") == 0) return O_RDONLY | O_SYNC;
if (strcmp(string, "rs+") == 0) return O_RDWR | O_SYNC;
return luaL_error(L, "Unknown file open flag'%s'", string);
}

Expand Down Expand Up @@ -229,7 +231,7 @@ uv_fs_t* luv_fs_store_callback(lua_State* L, int index) {
int luv_fs_open(lua_State* L) {
const char* path = luaL_checkstring(L, 1);
int flags = luv_string_to_flags(L, luaL_checkstring(L, 2));
int mode = strtoul(luaL_optstring(L, 3, "0666"), NULL, 8);
int mode = luaL_checkint(L, 3);
uv_fs_t* req = luv_fs_store_callback(L, 4);
FS_CALL(open, 4, path, path, flags, mode);
}
Expand Down

0 comments on commit 2b2e21e

Please sign in to comment.