4 Commits
1.7 ... 2.0

Author SHA1 Message Date
Hisham
b1f0f80141 Merge branch 'master' into 2.0 2016-10-19 01:36:11 -04:00
Peter Melnichenko
aa18f3e127 Don't declare global 'lfs' 2016-05-05 15:24:29 +03:00
Peter Melnichenko
6d6fd631ba Add a test for success return value of lfs.link 2016-05-05 15:10:56 +03:00
Peter Melnichenko
46bbddc5a2 Return true instead of 0 on lfs.link success 2016-05-05 12:46:54 +03:00
2 changed files with 4 additions and 11 deletions

View File

@@ -70,7 +70,6 @@
#include "lfs.h"
#define LFS_VERSION "1.6.3"
#define LFS_LIBNAME "lfs"
#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */
@@ -434,13 +433,7 @@ static int make_link (lua_State *L) {
#ifndef _WIN32
const char *oldpath = luaL_checkstring(L, 1);
const char *newpath = luaL_checkstring(L, 2);
int res = (lua_toboolean(L,3) ? symlink : link)(oldpath, newpath);
if (res == -1) {
return pusherror(L, NULL);
} else {
lua_pushinteger(L, 0);
return 1;
}
return pushresult(L, (lua_toboolean(L, 3) ? symlink : link)(oldpath, newpath), NULL);
#else
errno = ENOSYS; /* = "Function not implemented" */
return pushresult(L, -1, "make_link is not supported on Windows");
@@ -932,8 +925,6 @@ 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,7 +88,9 @@ io.write(".")
io.flush()
-- Checking link (does not work on Windows)
if lfs.link (tmpfile, "_a_link_for_test_", true) then
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")
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)