mirror of
https://github.com/lunarmodules/luafilesystem.git
synced 2026-07-22 19:13:05 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77c0e0f992 | ||
|
|
a332bde584 |
11
src/lfs.c
11
src/lfs.c
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user