aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2011-06-09 14:23:44 +0100
committerReuben Thomas <rrt@sc3d.org>2011-06-09 19:53:41 +0100
commit361cede4d08073183d3546a78763e7b62d6be9ef (patch)
treef86f63145c8dbd3a5cf99c785bfde60740d0a132 /src
parent3140ca4db8fbc35efaf44a4dd5176bfd0d99c713 (diff)
downloadluafilesystem-361cede4d08073183d3546a78763e7b62d6be9ef.tar.gz
luafilesystem-361cede4d08073183d3546a78763e7b62d6be9ef.tar.bz2
luafilesystem-361cede4d08073183d3546a78763e7b62d6be9ef.zip
Add trivial implementation of setmode on non-Windows platforms.
Diffstat (limited to 'src')
-rw-r--r--src/lfs.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 63d2dbd..e78aae6 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -100,8 +100,7 @@ typedef struct dir_data {
100#else 100#else
101#define _O_TEXT 0 101#define _O_TEXT 0
102#define _O_BINARY 0 102#define _O_BINARY 0
103#define lfs_setmode(L,file,m) ((void)((void)file,m), \ 103#define lfs_setmode(L,file,m) 0
104 luaL_error(L, LUA_QL("setmode") " not supported on this platform"), -1)
105#define STAT_STRUCT struct stat 104#define STAT_STRUCT struct stat
106#define STAT_FUNC stat 105#define STAT_FUNC stat
107#define LSTAT_FUNC lstat 106#define LSTAT_FUNC lstat
@@ -281,10 +280,9 @@ static int lfs_unlock_dir(lua_State *L) {
281} 280}
282#endif 281#endif
283 282
284#ifdef _WIN32
285static int lfs_g_setmode (lua_State *L, FILE *f, int arg) { 283static int lfs_g_setmode (lua_State *L, FILE *f, int arg) {
286 static const int mode[] = {_O_TEXT, _O_BINARY}; 284 static const int mode[] = {_O_BINARY, _O_TEXT};
287 static const char *const modenames[] = {"text", "binary", NULL}; 285 static const char *const modenames[] = {"binary", "text", NULL};
288 int op = luaL_checkoption(L, arg, NULL, modenames); 286 int op = luaL_checkoption(L, arg, NULL, modenames);
289 int res = lfs_setmode(L, f, mode[op]); 287 int res = lfs_setmode(L, f, mode[op]);
290 if (res != -1) { 288 if (res != -1) {
@@ -307,13 +305,6 @@ static int lfs_g_setmode (lua_State *L, FILE *f, int arg) {
307 return 3; 305 return 3;
308 } 306 }
309} 307}
310#else
311static int lfs_g_setmode (lua_State *L, FILE *f, int arg) {
312 lua_pushboolean(L, 0);
313 lua_pushliteral(L, "setmode not supported on this platform");
314 return 2;
315}
316#endif
317 308
318static int lfs_f_setmode(lua_State *L) { 309static int lfs_f_setmode(lua_State *L) {
319 return lfs_g_setmode(L, check_file(L, 1, "setmode"), 2); 310 return lfs_g_setmode(L, check_file(L, 1, "setmode"), 2);