6 Commits
v1_0b ... v1_0

Author SHA1 Message Date
tomas
12ff66217f Atualizacao para lancamento da versao 1.0 oficial 2005-01-19 14:30:08 +00:00
tomas
508c7b3b56 Eliminando funcao lfs.touch() para lancamento da versao 1.0 oficial. 2005-01-19 14:28:58 +00:00
tuler
e99b7844bb <sys/utime.h> in Windows. 2005-01-18 11:21:58 +00:00
tomas
86e97088a0 Acrescimo da funcao lfs.touch (lfs.c e test.lua).
Pequenas correcoes para evitar warnings de redefinicao de macros.
2005-01-18 10:48:02 +00:00
tomas
7a93f7ee03 Uniformizacao de nomes de variaveis entre as bibliotecas do Kepler.
Melhorias para reutilizacao do Makefile.
2005-01-18 09:36:11 +00:00
tomas
9dc07b0ada Retirando o artigo (The) dos links para o Projeto Kepler. 2004-12-28 16:39:51 +00:00
6 changed files with 103 additions and 58 deletions

View File

@@ -1,10 +1,10 @@
# $Id: Makefile,v 1.9 2004/11/10 14:44:01 tuler Exp $ # $Id: Makefile,v 1.12 2005/01/19 14:28:58 tomas Exp $
T= lfs T= lfs
include ./config include ./config
V= 1.0b V= 1.0
DIST_DIR= luafilesystem-$V DIST_DIR= luafilesystem-$V
TAR_FILE= $(DIST_DIR).tar.gz TAR_FILE= $(DIST_DIR).tar.gz
ZIP_FILE= $(DIST_DIR).zip ZIP_FILE= $(DIST_DIR).zip
@@ -23,9 +23,9 @@ compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c
$(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c
install: $(LIBNAME) install: $(LIBNAME)
mkdir -p $(LIB_DIR) mkdir -p $(LUA_LIBDIR)
cp $(LIBNAME) $(LIB_DIR) cp $(LIBNAME) $(LUA_LIBDIR)
ln -f -s $(LIB_DIR)/$(LIBNAME) $(LIB_DIR)/$T$(LIB_EXT) ln -f -s $(LUA_LIBDIR)/$(LIBNAME) $(LUA_LIBDIR)/$T$(LIB_EXT)
clean: clean:
rm -f $L $(LIBNAME) $(OBJS) rm -f $L $(LIBNAME) $(OBJS)

10
config
View File

@@ -1,8 +1,10 @@
# Installation directories # Installation directories
# System's libraries directory (where binary libraries are installed) # System's libraries directory (where binary libraries are installed)
LIB_DIR= /usr/local/lib LUA_LIBDIR= /usr/local/lib/lua/5.0
# System's lua directory (where Lua libraries are installed) # System's lua directory (where Lua libraries are installed)
LUA_DIR= /usr/local/lua LUA_DIR= /usr/local/share/lua/5.0
# Lua includes directory
LUA_INC= /usr/local/include/lua5
# OS dependent # OS dependent
LIB_EXT= .dylib LIB_EXT= .dylib
@@ -16,8 +18,8 @@ COMPAT_DIR= .
# On FreeBSD systems, the following line should be commented # On FreeBSD systems, the following line should be commented
DLLIB= -ldl DLLIB= -ldl
WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings
INCS= -I/usr/local/include/lua5 -I$(COMPAT_DIR) INCS= -I$(LUA_INC) -I$(COMPAT_DIR)
LIBS= -L$(LIB_DIR) -llua -llualib -lm $(DLLIB) LIBS= -L$(LUA_LIBDIR) -llua -llualib -lm $(DLLIB)
CFLAGS= $(WARN) $(INCS) CFLAGS= $(WARN) $(INCS)
CC= gcc CC= gcc

View File

@@ -26,10 +26,13 @@ href="http://www.lua.org">Lua</a> Programming Language</td>
</table> </table>
</center> </center>
<center><small><a href="#over">overview</a> &middot; <a href= <center><small>
"#download">download</a> &middot; <a href="manual.html">manual</a> <a href="#over">overview</a> &middot;
&middot; <a href="#credits">credits</a> &middot; <a href= <a href="#download">download</a> &middot;
"#contact">contact us</a></small></center> <a href="manual.html">manual</a> &middot;
<a href="#credits">credits</a> &middot;
<a href="#contact">contact us</a>
</small></center>
<hr> <hr>
<h2>Contents</h2> <h2>Contents</h2>
@@ -61,27 +64,32 @@ distribution. One of its goals is to be as portable as Lua.</p>
<h2>Current version</h2> <h2>Current version</h2>
<p>Current version is 1.0 beta. It was developed for Lua 5.0.</p> <p>Current version is 1.0. It was developed for Lua 5.0.</p>
<p>Version 1.0 follows the <a href= <p>Version 1.0 follows the
"http://www.keplerproject.org/compat">package proposal</a> for Lua <a href="http://www.keplerproject.org/compat">package proposal</a>
5.1 (see section <a href="#installation">Installation</a> for more for Lua 5.1 (see section <a href="#installation">Installation</a>
details). <a name="download"></a></p> for more details).
</p>
<a name="download"></a>
<h2>Download</h2> <h2>Download</h2>
<p>LuaFileSystem can be downloaded from its <a href= <p>
"http://luaforge.net/project/showfiles.php?group_id=66">Lua LuaFileSystem can be downloaded from its
Forge</a> page. <a name="new"></a></p> <a href="http://luaforge.net/project/showfiles.php?group_id=66">Lua Forge</a>
page.
</p>
<a name="new"></a>
<h2>What's new</h2> <h2>What's new</h2>
<ul> <ul>
<li>[10/nov/2004] Version 1.0 beta released</li> <li>[21/Jan/2005] Version 1.0 released</li>
<li>[10/Nov/2004] Version 1.0 beta released</li>
</ul> </ul>
<a name="installation"></a> <a name="installation"></a>
<h2>Installation</h2> <h2>Installation</h2>
<p>LuaFileSystem is distributed as a pair of C source and header <p>LuaFileSystem is distributed as a pair of C source and header
@@ -89,25 +97,24 @@ files. The distribution provides a <tt>Makefile</tt> prepared to
compile the library and install it. The file <tt>config</tt> should compile the library and install it. The file <tt>config</tt> should
be edited to suit the needs of the aimed platform.</p> be edited to suit the needs of the aimed platform.</p>
<p>LuaFileSystem follows the <a href= <p>LuaFileSystem follows the
"http://www.keplerproject.org/compat">package proposal</a> for Lua <a href="http://www.keplerproject.org/compat">package proposal</a>
5.1, therefore this package should be "installed". In other words, for Lua 5.1, therefore this package should be "installed".
In other words,
if you are using Lua 5.0, the files <tt>compat-5.1.c</tt> and if you are using Lua 5.0, the files <tt>compat-5.1.c</tt> and
<tt>compat-5.1.h</tt> must be used in the compilation and the file <tt>compat-5.1.h</tt> must be used in the compilation and the file
<tt>compat-5.1.lua</tt> must be installed in the <tt>LUA_PATH</tt>. <tt>compat-5.1.lua</tt> must be installed in the <tt>LUA_PATH</tt>.
If you are using Lua 5.1, nothing should be done.</p> If you are using Lua 5.1, nothing should be done.</p>
<a name="credits"></a> <a name="credits"></a>
<h2>Credits</h2> <h2>Credits</h2>
<p>LuaFileSystem was designed by Roberto Ierusalimschy, <p>LuaFileSystem was designed by Roberto Ierusalimschy,
Andr&eacute; Carregal and Tom&aacute;s Guisasola as part of <a Andr&eacute; Carregal and Tom&aacute;s Guisasola as part of the
href="http://www.keplerproject.org">The Kepler Project</a> which <a href="http://www.keplerproject.org">Kepler Project</a>
holds its copyright.</p> which holds its copyright.</p>
<a name="contact"></a> <a name="contact"></a>
<h2>Contact us</h2> <h2>Contact us</h2>
<p>For more information please <a href= <p>For more information please <a href=
@@ -115,8 +122,7 @@ holds its copyright.</p>
Comments are welcome!</p> Comments are welcome!</p>
<hr> <hr>
<small>$Id: index.html,v 1.6 2004/11/11 15:33:20 tomas Exp <small>$Id: index.html,v 1.9 2005/01/19 14:30:08 tomas Exp $</small>
$</small>
</body> </body>
</html> </html>

View File

@@ -11,13 +11,15 @@
LuaFileSystem is free software: it can be used for both academic LuaFileSystem is free software: it can be used for both academic
and commercial purposes at absolutely no cost. There are no and commercial purposes at absolutely no cost. There are no
royalties or GNU-like "copyleft" restrictions. LuaFileSystem royalties or GNU-like "copyleft" restrictions. LuaFileSystem
qualifies as <a href= qualifies as
"http://www.opensource.org/docs/definition.html">Open Source</a> <a href="http://www.opensource.org/docs/definition.html">Open Source</a>
software. Its licenses are compatible with <a href= software.
"http://www.gnu.org/licenses/gpl.html">GPL</a>. LuaFileSystem is Its licenses are compatible with
not in the public domain and <a href= <a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.
"http://www.keplerproject.org">The Kepler Project</a> keep its LuaFileSystem is not in the public domain and the
copyright. The legal details are below. <a href="http://www.keplerproject.org">Kepler Project</a>
keep its copyright.
The legal details are below.
<p>The spirit of the license is that you are free to use <p>The spirit of the license is that you are free to use
LuaFileSystem for any purpose at no cost without having to ask us. LuaFileSystem for any purpose at no cost without having to ask us.
@@ -34,7 +36,7 @@ The implementation is not derived from licensed software.</p>
</p> </p>
<hr> <hr>
Copyright &copy; 2004 The Kepler Project. Copyright &copy; 2004-2005 The Kepler Project.
<p>Permission is hereby granted, free of charge, to any person <p>Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@@ -61,8 +63,7 @@ SOFTWARE.</p>
</p> </p>
<hr> <hr>
<small>$Id: license.html,v 1.1.1.1 2004/07/27 14:15:24 tomas Exp <small>$Id: license.html,v 1.4 2005/01/19 14:30:08 tomas Exp $</small>
$</small>
</body> </body>
</html> </html>

View File

@@ -9,7 +9,7 @@
** lfs.lock (fh, mode) ** lfs.lock (fh, mode)
** lfs.unlock (fh) ** lfs.unlock (fh)
** **
** $Id: lfs.c,v 1.14 2004/11/17 14:08:04 tomas Exp $ ** $Id: lfs.c,v 1.17 2005/01/19 14:28:58 tomas Exp $
*/ */
#include <errno.h> #include <errno.h>
@@ -131,7 +131,7 @@ static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long star
case 'r': lkmode = _LK_NBLCK; break; case 'r': lkmode = _LK_NBLCK; break;
case 'w': lkmode = _LK_NBLCK; break; case 'w': lkmode = _LK_NBLCK; break;
case 'u': lkmode = _LK_UNLCK; break; case 'u': lkmode = _LK_UNLCK; break;
default : luaL_error (L, "%s: invalid mode", funcname); default : return luaL_error (L, "%s: invalid mode", funcname);
} }
if (!len) { if (!len) {
fseek (fh, 0L, SEEK_END); fseek (fh, 0L, SEEK_END);
@@ -145,7 +145,7 @@ static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long star
case 'w': f.l_type = F_WRLCK; break; case 'w': f.l_type = F_WRLCK; break;
case 'r': f.l_type = F_RDLCK; break; case 'r': f.l_type = F_RDLCK; break;
case 'u': f.l_type = F_UNLCK; break; case 'u': f.l_type = F_UNLCK; break;
default : luaL_error (L, "%s: invalid mode", funcname); default : return luaL_error (L, "%s: invalid mode", funcname);
} }
f.l_whence = SEEK_SET; f.l_whence = SEEK_SET;
f.l_start = (off_t)start; f.l_start = (off_t)start;
@@ -345,13 +345,27 @@ static int dir_create_meta (lua_State *L) {
#ifdef _WIN32 #ifdef _WIN32
#define S_ISDIR(mode) (mode&_S_IFDIR) #ifndef S_ISDIR
#define S_ISREG(mode) (mode&_S_IFREG) #define S_ISDIR(mode) (mode&_S_IFDIR)
#define S_ISLNK(mode) (0) #endif
#define S_ISSOCK(mode) (0) #ifndef S_ISREG
#define S_ISFIFO(mode) (0) #define S_ISREG(mode) (mode&_S_IFREG)
#define S_ISCHR(mode) (mode&_S_IFCHR) #endif
#define S_ISBLK(mode) (0) #ifndef S_ISLNK
#define S_ISLNK(mode) (0)
#endif
#ifndef S_ISSOCK
#define S_ISSOCK(mode) (0)
#endif
#ifndef S_ISFIFO
#define S_ISFIFO(mode) (0)
#endif
#ifndef S_ISCHR
#define S_ISCHR(mode) (mode&_S_IFCHR)
#endif
#ifndef S_ISBLK
#define S_ISBLK(mode) (0)
#endif
#endif #endif
/* /*
** Convert the inode protection mode to a string. ** Convert the inode protection mode to a string.
@@ -457,7 +471,7 @@ static int file_info (lua_State *L) {
*/ */
static void set_info (lua_State *L) { static void set_info (lua_State *L) {
lua_pushliteral (L, "_COPYRIGHT"); lua_pushliteral (L, "_COPYRIGHT");
lua_pushliteral (L, "Copyright (C) 2004 Kepler Project"); lua_pushliteral (L, "Copyright (C) 2004-2005 Kepler Project");
lua_settable (L, -3); lua_settable (L, -3);
lua_pushliteral (L, "_DESCRIPTION"); lua_pushliteral (L, "_DESCRIPTION");
lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution");
@@ -466,7 +480,7 @@ static void set_info (lua_State *L) {
lua_pushliteral (L, "LuaFileSystem"); lua_pushliteral (L, "LuaFileSystem");
lua_settable (L, -3); lua_settable (L, -3);
lua_pushliteral (L, "_VERSION"); lua_pushliteral (L, "_VERSION");
lua_pushliteral (L, "1.0b"); lua_pushliteral (L, "1.0");
lua_settable (L, -3); lua_settable (L, -3);
} }

View File

@@ -32,9 +32,31 @@ assert (lfs.chdir (reldir), "could not change back to current directory")
assert (lfs.currentdir() == current, "error trying to change directories") assert (lfs.currentdir() == current, "error trying to change directories")
assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory") assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory")
-- Changing creating and removing directories -- Changing creating and removing directories
assert (lfs.mkdir (tmp.."/lfs_tmp_dir"), "could not make a new directory") local tmpdir = tmp.."/lfs_tmp_dir"
assert (os.remove (tmp.."/lfs_tmp_dir"), "could not remove new directory") assert (lfs.mkdir (tmpdir), "could not make a new directory")
assert (lfs.mkdir (tmp.."/lfs_tmp_dir/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") local attrib, errmsg = lfs.attributes (tmpdir)
if not attrib then
error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg)
else
-- Change access time
assert (lfs.touch (tmpdir, 11))
local new_att = assert (lfs.attributes (tmpdir))
assert (new_att.access == 11, "could not set access time")
assert (new_att.modification == 11, "could not set modification time")
-- Change access and modification time
assert (lfs.touch (tmpdir, 33, 22))
local new_att = assert (lfs.attributes (tmpdir))
assert (new_att.access == 33, "could not set access time")
assert (new_att.modification == 22, "could not set modification time")
-- Restore access time to current value
assert (lfs.touch (tmpdir))
new_att = assert (lfs.attributes (tmpdir))
assert (new_att.access == attrib.access)
assert (new_att.modification == attrib.modification)
end
assert (os.remove (tmpdir), "could not remove new directory")
assert (lfs.mkdir (tmpdir.."/lfs_tmp_dir") == false, "could create a directory inside a non-existent one")
-- --
assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file")
assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory") assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory")
print"Ok!"