aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-06-21 10:48:11 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-06-21 10:48:11 +0300
commita332bde584756b14298f51e913bdc309f87e7ff8 (patch)
treebed97d0cefa34dba06344b99d1abc9b2e2c7e2cb
parent81e5b165bf324689777b967143c751786c405ce4 (diff)
parent7fae11cdb5a129ce798df462365b7ce60c5f4d62 (diff)
downloadluafilesystem-a332bde584756b14298f51e913bdc309f87e7ff8.tar.gz
luafilesystem-a332bde584756b14298f51e913bdc309f87e7ff8.tar.bz2
luafilesystem-a332bde584756b14298f51e913bdc309f87e7ff8.zip
Merge branch 'master' into 1.7
-rw-r--r--src/lfs.c2
-rw-r--r--src/lfs.h24
-rw-r--r--tests/test.lua3
3 files changed, 17 insertions, 12 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 0387e15..dd0b6af 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -875,7 +875,7 @@ static const struct luaL_Reg fslib[] = {
875 {NULL, NULL}, 875 {NULL, NULL},
876}; 876};
877 877
878int luaopen_lfs (lua_State *L) { 878LFS_EXPORT int luaopen_lfs (lua_State *L) {
879 dir_create_meta (L); 879 dir_create_meta (L);
880 lock_create_meta (L); 880 lock_create_meta (L);
881 luaL_newlib (L, fslib); 881 luaL_newlib (L, fslib);
diff --git a/src/lfs.h b/src/lfs.h
index a621d04..7f7d2ab 100644
--- a/src/lfs.h
+++ b/src/lfs.h
@@ -5,27 +5,29 @@
5 5
6/* Define 'chdir' for systems that do not implement it */ 6/* Define 'chdir' for systems that do not implement it */
7#ifdef NO_CHDIR 7#ifdef NO_CHDIR
8#define chdir(p) (-1) 8 #define chdir(p) (-1)
9#define chdir_error "Function 'chdir' not provided by system" 9 #define chdir_error "Function 'chdir' not provided by system"
10#else 10#else
11#define chdir_error strerror(errno) 11 #define chdir_error strerror(errno)
12
13#endif 12#endif
14 13
15#ifdef _WIN32 14#ifdef _WIN32
16#define chdir(p) (_chdir(p)) 15 #define chdir(p) (_chdir(p))
17#define getcwd(d, s) (_getcwd(d, s)) 16 #define getcwd(d, s) (_getcwd(d, s))
18#define rmdir(p) (_rmdir(p)) 17 #define rmdir(p) (_rmdir(p))
19#ifndef fileno 18 #define LFS_EXPORT __declspec (dllexport)
20#define fileno(f) (_fileno(f)) 19 #ifndef fileno
21#endif 20 #define fileno(f) (_fileno(f))
21 #endif
22#else
23 #define LFS_EXPORT
22#endif 24#endif
23 25
24#ifdef __cplusplus 26#ifdef __cplusplus
25extern "C" { 27extern "C" {
26#endif 28#endif
27 29
28int luaopen_lfs (lua_State *L); 30LFS_EXPORT int luaopen_lfs (lua_State *L);
29 31
30#ifdef __cplusplus 32#ifdef __cplusplus
31} 33}
diff --git a/tests/test.lua b/tests/test.lua
index 5872717..193e0bd 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -107,6 +107,9 @@ assert(result) -- on non-Windows platforms, mode is always returned as "binary"
107result, mode = lfs.setmode(f, "text") 107result, mode = lfs.setmode(f, "text")
108assert(result and mode == "binary") 108assert(result and mode == "binary")
109f:close() 109f:close()
110local ok, err = pcall(lfs.setmode, f, "binary")
111assert(not ok, "could setmode on closed file")
112assert(err:find("closed file"), "bad error message for setmode on closed file")
110 113
111io.write(".") 114io.write(".")
112io.flush() 115io.flush()