Skip to content

Commit

Permalink
win32: strip UNC prefix if present
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Apr 21, 2020
1 parent 33a8649 commit 8f764ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ static int push_link_target(lua_State *L) {
break;
}
if (tsize < size) {
#ifdef _WIN32
if (tsize > 4 && strncmp(target, "\\\\?\\", 4) == 0) {
memmove_s(target, tsize - 3, target + 4, tsize - 3);
}
#endif
ok = 1;
break;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ io.flush()
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")
print("TMPFILE " .. tmpfile)
print("TARGET " .. lfs.symlinkattributes"_a_link_for_test_".target)
print("TMPFILE ", string.byte(tmpfile, 1, #tmpfile))
local tgt = lfs.symlinkattributes"_a_link_for_test_".target
print("TARGET ", string.byte(tgt, 1, #tgt))
io.flush()
assert (lfs.symlinkattributes"_a_link_for_test_".target == tmpfile)
assert (lfs.symlinkattributes("_a_link_for_test_", "target") == tmpfile)
Expand Down

0 comments on commit 8f764ff

Please sign in to comment.