aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2011-06-09 14:01:37 +0100
committerReuben Thomas <rrt@sc3d.org>2011-06-09 19:53:41 +0100
commit530c9140c7628f7062e2caff73c94e547ea0c45f (patch)
treeef6cb15541530ea6cea22999769132f43c80c70e
parentd292b3243f90ba21450c0599b42aa89e999524ee (diff)
downloadluafilesystem-530c9140c7628f7062e2caff73c94e547ea0c45f.tar.gz
luafilesystem-530c9140c7628f7062e2caff73c94e547ea0c45f.tar.bz2
luafilesystem-530c9140c7628f7062e2caff73c94e547ea0c45f.zip
Add trivial link_info support on Windows (using STAT_FUNC).
-rw-r--r--doc/us/manual.html4
-rw-r--r--src/lfs.c9
-rw-r--r--tests/test.lua12
3 files changed, 8 insertions, 17 deletions
diff --git a/doc/us/manual.html b/doc/us/manual.html
index 217c249..a5843ed 100644
--- a/doc/us/manual.html
+++ b/doc/us/manual.html
@@ -228,8 +228,8 @@ LuaFileSystem offers the following functions:
228 <dt><a name="symlinkattributes"></a><strong><code>lfs.symlinkattributes (filepath [, aname])</code></strong></dt> 228 <dt><a name="symlinkattributes"></a><strong><code>lfs.symlinkattributes (filepath [, aname])</code></strong></dt>
229 <dd>Identical to <a href="#attributes">lfs.attributes</a> except that 229 <dd>Identical to <a href="#attributes">lfs.attributes</a> except that
230 it obtains information about the link itself (not the file it refers to). 230 it obtains information about the link itself (not the file it refers to).
231 This function is not available in Windows so you may want to make sure that 231 On Windows this function does not yet support links, and is identical to
232 <code>lfs.symlinkattributes</code> exists before using it. 232 <code>lfs.attributes</code>.
233 </dd> 233 </dd>
234 234
235 <dt><a name="touch"></a><strong><code>lfs.touch (filepath [, atime [, mtime]])</code></strong></dt> 235 <dt><a name="touch"></a><strong><code>lfs.touch (filepath [, atime [, mtime]])</code></strong></dt>
diff --git a/src/lfs.c b/src/lfs.c
index 8e94d4f..63d2dbd 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -96,6 +96,7 @@ typedef struct dir_data {
96 #define STAT_STRUCT struct _stati64 96 #define STAT_STRUCT struct _stati64
97 #endif 97 #endif
98#define STAT_FUNC _stati64 98#define STAT_FUNC _stati64
99#define LSTAT_FUNC STAT_FUNC
99#else 100#else
100#define _O_TEXT 0 101#define _O_TEXT 0
101#define _O_BINARY 0 102#define _O_BINARY 0
@@ -743,17 +744,9 @@ static int file_info (lua_State *L) {
743/* 744/*
744** Get symbolic link information using lstat. 745** Get symbolic link information using lstat.
745*/ 746*/
746#ifndef _WIN32
747static int link_info (lua_State *L) { 747static int link_info (lua_State *L) {
748 return _file_info_ (L, LSTAT_FUNC); 748 return _file_info_ (L, LSTAT_FUNC);
749} 749}
750#else
751static int link_info (lua_State *L) {
752 lua_pushboolean(L, 0);
753 lua_pushliteral(L, "symlinkattributes not supported on this platform");
754 return 2;
755}
756#endif
757 750
758 751
759/* 752/*
diff --git a/tests/test.lua b/tests/test.lua
index 7111074..6af7e9b 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -69,13 +69,11 @@ local new_att = assert (lfs.attributes (tmpfile))
69assert (new_att.access == testdate2, "could not set access time") 69assert (new_att.access == testdate2, "could not set access time")
70assert (new_att.modification == testdate1, "could not set modification time") 70assert (new_att.modification == testdate1, "could not set modification time")
71 71
72local res, err = lfs.symlinkattributes(tmpfile) 72-- Checking symbolic link information (does not work in Windows)
73if err ~= "symlinkattributes not supported on this platform" then 73if (os.execute ("ln -s "..tmpfile.." _a_link_for_test_")) then
74 -- Checking symbolic link information (does not work in Windows) 74 assert (lfs.attributes"_a_link_for_test_".mode == "file")
75 assert (os.execute ("ln -s "..tmpfile.." _a_link_for_test_")) 75 assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
76 assert (lfs.attributes"_a_link_for_test_".mode == "file") 76 assert (os.remove"_a_link_for_test_")
77 assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
78 assert (os.remove"_a_link_for_test_")
79end 77end
80 78
81if lfs.setmode then 79if lfs.setmode then