mirror of
https://github.com/lunarmodules/luafilesystem.git
synced 2026-07-24 03:53:06 +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"
|
#include "lfs.h"
|
||||||
|
|
||||||
#define LFS_VERSION "1.6.3"
|
#define LFS_VERSION "1.6.3"
|
||||||
|
#define LFS_LIBNAME "lfs"
|
||||||
|
|
||||||
#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */
|
#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */
|
||||||
|
|
||||||
@@ -433,7 +434,13 @@ static int make_link (lua_State *L) {
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
const char *oldpath = luaL_checkstring(L, 1);
|
const char *oldpath = luaL_checkstring(L, 1);
|
||||||
const char *newpath = luaL_checkstring(L, 2);
|
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
|
#else
|
||||||
errno = ENOSYS; /* = "Function not implemented" */
|
errno = ENOSYS; /* = "Function not implemented" */
|
||||||
return pushresult(L, -1, "make_link is not supported on Windows");
|
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);
|
dir_create_meta (L);
|
||||||
lock_create_meta (L);
|
lock_create_meta (L);
|
||||||
luaL_newlib (L, fslib);
|
luaL_newlib (L, fslib);
|
||||||
|
lua_pushvalue(L, -1);
|
||||||
|
lua_setglobal(L, LFS_LIBNAME);
|
||||||
set_info (L);
|
set_info (L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,9 +88,7 @@ io.write(".")
|
|||||||
io.flush()
|
io.flush()
|
||||||
|
|
||||||
-- Checking link (does not work on Windows)
|
-- Checking link (does not work on Windows)
|
||||||
local link_ok = lfs.link (tmpfile, "_a_link_for_test_", true)
|
if lfs.link (tmpfile, "_a_link_for_test_", true) then
|
||||||
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.attributes"_a_link_for_test_".mode == "file")
|
||||||
assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
|
assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
|
||||||
assert (lfs.symlinkattributes"_a_link_for_test_".target == tmpfile)
|
assert (lfs.symlinkattributes"_a_link_for_test_".target == tmpfile)
|
||||||
|
|||||||
Reference in New Issue
Block a user