2 Commits
2.0 ... 1.7

Author SHA1 Message Date
Hisham
77c0e0f992 Merge branch 'master' into 1.7 2016-10-19 01:35:24 -04:00
Peter Melnichenko
a332bde584 Merge branch 'master' into 1.7 2016-06-21 10:48:11 +03:00
2 changed files with 11 additions and 4 deletions

View File

@@ -70,6 +70,7 @@
#include "lfs.h"
#define LFS_VERSION "1.6.3"
#define LFS_LIBNAME "lfs"
#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */
@@ -433,7 +434,13 @@ static int make_link (lua_State *L) {
#ifndef _WIN32
const char *oldpath = luaL_checkstring(L, 1);
const char *newpath = luaL_checkstring(L, 2);
return pushresult(L, (lua_toboolean(L, 3) ? symlink : link)(oldpath, newpath), NULL);
int res = (lua_toboolean(L,3) ? symlink : link)(oldpath, newpath);
if (res == -1) {
return pusherror(L, NULL);
} else {
lua_pushinteger(L, 0);
return 1;
}
#else
errno = ENOSYS; /* = "Function not implemented" */
return pushresult(L, -1, "make_link is not supported on Windows");
@@ -925,6 +932,8 @@ LFS_EXPORT int luaopen_lfs (lua_State *L) {
dir_create_meta (L);
lock_create_meta (L);
luaL_newlib (L, fslib);
lua_pushvalue(L, -1);
lua_setglobal(L, LFS_LIBNAME);
set_info (L);
return 1;
}

View File

@@ -88,9 +88,7 @@ io.write(".")
io.flush()
-- Checking link (does not work on Windows)
local link_ok = lfs.link (tmpfile, "_a_link_for_test_", true)
if link_ok then
assert (link_ok == true, "successful lfs.link did not return true")
if lfs.link (tmpfile, "_a_link_for_test_", true) then
assert (lfs.attributes"_a_link_for_test_".mode == "file")
assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
assert (lfs.symlinkattributes"_a_link_for_test_".target == tmpfile)