48 Commits

Author SHA1 Message Date
Hisham Muhammad
7c6e1b013c Release 1.8.0 2020-04-22 22:16:42 -03:00
Hisham Muhammad
68c624c686 It does work on Windows now! 2020-04-22 22:12:23 -03:00
Hisham Muhammad
41e59da31b update copyrights 2020-04-22 22:09:38 -03:00
Hisham Muhammad
842505b6a3 Lua 5.4: use __close to close dir if you break the iterator 2020-04-22 11:30:28 -03:00
Hisham Muhammad
3e879ffba1 indent -kr -nut -i2 src/lfs.c src/lfs.h 2020-04-22 11:30:28 -03:00
Hisham Muhammad
4f7e1b5a49 Makefile: make it easier to switch Lua versions 2020-04-21 18:41:55 -03:00
云风
a5336d294d Use CREATE_ALWAYS instead of CREATE_NEW 2020-04-21 18:36:43 -03:00
Hisham Muhammad
6048863a96 tests: behavior test for hard links
Also check nlink on Unix only
and test if something is a symlink
2020-04-21 13:45:50 -03:00
Hisham Muhammad
1a61e5284d win32: strip UNC prefix if present 2020-04-21 13:45:50 -03:00
Hisham Muhammad
7cb7d86dc4 win32 lstat: if it's not a link, just do stat 2020-04-21 13:45:50 -03:00
Hisham Muhammad
94700f7c18 win32: obtain symlink attributes 2020-04-21 13:45:50 -03:00
Eroica
53d2acc517 Add Windows compatibility for lfs.link
Co-Authored-By: Hisham Muhammad <hisham@gobolinux.org>
2020-04-21 13:45:50 -03:00
Hisham Muhammad
6b11508ea9 tests: drop LuaJIT 2.0 from test matrix 2020-04-21 13:45:50 -03:00
Joshua Root
58cf8c9449 Make MACOSX_DEPLOYMENT_TARGET configurable
Also increase the default target to 10.5, since Xcode 10 can no longer
target 10.3.
2020-04-20 21:36:11 -03:00
Peter Melnichenko
04ba8d686a Support Lua 5.4 2020-04-20 18:50:38 -03:00
James McCoy
04bdaf9a1e Fallback to _POSIX_PATH_MAX when MAXPATHLEN isn't available (#130)
On systems where MAXPATHLEN isn't defined, like GNU/Hurd, use
_POSIX_PATH_MAX as the starting size for the getcwd() buffer.
2019-10-29 16:08:55 -04:00
Peter Melnichenko
1dfb8c41e8 Replace rockspecs/ with a single scm rockspec (#108)
There is no need to keep rockspecs for older versions - it's enough
to ensure that `luarocks make` builds currently checked out version.

`luarocks new-version <rockspec> <version> --tag=<tag>` generates
rockspecs for releases.

Use `scm` instead of `dev` as LuaRocks 2 thinks that `dev` versions
are less than normal versions like 1.6.3, making it tricky to
use bleeding-edge version as a dependency with a constraint
such as `luafilesystem >= 1.6.3`.
2018-03-15 20:38:32 -03:00
TsT
37d8524e7e lfs.attributes and lfs.symlinkattributes arguments renamed s/aname/request_name/ s/atable/result_table/ (#106) 2017-12-14 18:12:18 -02:00
Kıvanç Çakmak
e5f06c270a added extra include-dir to compile in ubuntu (#103) 2017-11-29 20:12:28 -02:00
Hisham Muhammad
884b52a3b2 Fix memory leak in case of realloc failure. (#102)
Fixes #101.
2017-11-27 14:03:38 -02:00
Hisham Muhammad
1b5073419f Merge branch 'master' of https://github.com/keplerproject/luafilesystem 2017-11-26 16:44:49 -02:00
Stephen E. Baker
fe964e013d Update version in lfs.def (#96)
Version number of current release is 1.7
2017-10-08 17:03:08 -03:00
Dan Church
12d1692f14 Support DESTDIR make install option (#98)
Useful for packagers to specify a build jail to install into.
2017-10-08 17:01:53 -03:00
Hisham Muhammad
de87218e97 Add rockspec for hotfix. 2017-09-15 20:07:33 -03:00
Hisham Muhammad
a23cadf009 Fix _VERSION entry
Thanks Milind Gupta for noting!
2017-09-15 20:04:43 -03:00
Hisham Muhammad
220d38c7d1 Update for release 1.7.0. 2017-09-15 19:52:00 -03:00
Hisham Muhammad
a066a03f1c First iteration of the new CSS for Kepler libraries 2017-09-15 19:51:46 -03:00
Hisham Muhammad
d37fc8101a Add rockspec for 1.7.0 2017-09-15 19:51:07 -03:00
Peter Melnichenko
754576dee6 Add 'unreleased' section to changelog in docs 2017-09-14 15:46:13 +03:00
Peter Melnichenko
d399961536 Merge branch '1.7' 2017-09-14 12:15:58 +03:00
Peter Melnichenko
8a7796ec17 Typo fix in README 2017-09-14 12:12:14 +03:00
Peter Melnichenko
dd6911ef15 Update copyright year [ci skip] 2017-09-14 12:10:39 +03:00
Peter Melnichenko
55ed1b14ab README corrections [ci skip] 2017-09-14 12:05:49 +03:00
Peter Melnichenko
a84d81bc52 Fix compilation warning for LuaJIT 2.1
Do not redefine or reimplement standard Lua C API function
luaL_newlib, use another name (new_lib) instead.
2017-09-14 12:01:00 +03:00
Peter Melnichenko
a90ec38133 Update luacov-coveralls deps installation in .travis.yml 2017-09-11 15:39:09 +03:00
Peter Melnichenko
ee5942d810 Add LuaJIT 2.1 to Travis-CI matrix 2017-09-11 13:53:28 +03:00
NiteHawk
3c4e563d9c Dynamically size getcwd() buffer in get_dir function (#84)
* Dynamically size getcwd() buffer in get_dir function

This should fix issue 42.

* Fixup: Properly respect NO_GETCWD

* Fixup: Get rid of getcwd_error, handle NO_GETCWD in a single place
2016-10-14 15:46:54 -07:00
Peter Melnichenko
50919ed69f Fix lfs.attributes and lfs.symlinkattributes extra argument handling
When the second argument is not a string, _file_info() wants to
ensure that there is a table on top of the stack: the second argument
or a new table. If a new table is pushed it's created on top immediately,
but if a table is passed as the second argument it can be followed
by extra arguments, with the last one ending up being used as a table,
causing a crash. The fix is to remove any potential extra arguments
using `lua_settop(L, 2)`.

Also added a few tests for this case. Ref #80.
2016-08-25 18:31:09 +03:00
Hisham Muhammad
4cf702d850 Merge pull request #78 from n1tehawk/20160716_symlink-target
Add a 'target' field for symlinkattributes.
2016-07-17 22:10:31 -03:00
NiteHawk
32b355a990 Add a 'target' field for symlinkattributes.
It returns the resolved path of the symlink.

Original version by Hisham <hisham@gobolinux.org>, modified to
use a different strategy for sizing the readlink() buffer.
2016-07-16 15:35:27 +02:00
Peter Melnichenko
080f74f785 Fix anchor names in documentation 2016-06-30 21:17:54 +03:00
Peter Melnichenko
a332bde584 Merge branch 'master' into 1.7 2016-06-21 10:48:11 +03:00
Peter Melnichenko
81e5b165bf Update docs for new return values 2016-05-05 12:39:17 +03:00
Peter Melnichenko
8d5f9661e9 Test what lfs.attributes returns on error 2016-05-05 12:39:17 +03:00
Peter Melnichenko
b37e88b3d6 Return errno from lfs.attributes on error 2016-05-05 12:39:17 +03:00
Peter Melnichenko
8f167ef1de Return errno from lfs.touch on error 2016-05-05 12:39:17 +03:00
Peter Melnichenko
8b85d257a6 Return errno from lfs.rmdir on error 2016-05-05 12:39:17 +03:00
Peter Melnichenko
d186dda4d7 Return errno from lfs.mkdir on error
Change pushresult() to return true on success.
Change make_link to keep returning 0.
2016-05-05 12:38:28 +03:00
28 changed files with 1070 additions and 1127 deletions

View File

@@ -6,21 +6,20 @@ env:
- LUA="lua 5.1"
- LUA="lua 5.2"
- LUA="lua 5.3"
- LUA="luajit 2.0"
- LUA="luajit 2.1"
before_install:
- pip install --user cpp-coveralls hererocks
- hererocks env --$LUA --luarocks latest
- export PATH="$PWD/env/bin:$PATH"
- luarocks install Lua-cURL --server=https://luarocks.org/dev
- luarocks install lua-path
- luarocks install lua-cjson
- luarocks install dkjson
- luarocks install luacov
# install luacov-coveralls, but avoids installing luafilesystem
# install luacov-coveralls, but avoid installing luafilesystem
- luarocks install luacov-coveralls --server=https://luarocks.org/dev --deps-mode=none
install:
- luarocks make rockspecs/luafilesystem-cvs-3.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage"
- luarocks make CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage"
script:
- lua -lluacov tests/test.lua

View File

@@ -12,14 +12,14 @@ OBJS= src/$T.o
lib: src/lfs.so
src/lfs.so: $(OBJS)
MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(LIB_OPTION) -o src/lfs.so $(OBJS)
MACOSX_DEPLOYMENT_TARGET=$(MACOSX_DEPLOYMENT_TARGET); export MACOSX_DEPLOYMENT_TARGET; $(CC) $(LIB_OPTION) -o src/lfs.so $(OBJS)
test: lib
LUA_CPATH=./src/?.so lua tests/test.lua
install:
mkdir -p $(LUA_LIBDIR)
cp src/lfs.so $(LUA_LIBDIR)
mkdir -p $(DESTDIR)$(LUA_LIBDIR)
cp src/lfs.so $(DESTDIR)$(LUA_LIBDIR)
clean:
rm -f src/lfs.so $(OBJS)

View File

@@ -1,12 +1,13 @@
[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENCE.txt)
[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/keplerproject/luafilesystem.svg?branch=master)](https://travis-ci.org/keplerproject/luafilesystem)
[![Build status](https://ci.appveyor.com/api/projects/status/y04s4ms7u16trw8e?svg=true)](https://ci.appveyor.com/project/ignacio/luafilesystem)
[![Coverage Status](https://coveralls.io/repos/keplerproject/luafilesystem/badge.png)](https://coveralls.io/r/keplerproject/luafilesystem)
# LuaFileSystem - File System Library for Lua
Copyright 2003-2016 Kepler Project
http://keplerproject.github.io/luafilesystem
Copyright 2003-2020 Kepler Project
https://keplerproject.github.io/luafilesystem
# Description
@@ -14,7 +15,7 @@ LuaFileSystem is a Lua library developed to complement the set of functions
related to file systems offered by the standard Lua distribution.
LuaFileSystem offers a portable way to access the underlying directory structure and file attributes.
LuaFileSystem is free software and uses the same license as Lua 5.1
LuaFileSystem is free software and uses the same license as Lua 5.x (MIT).
# LuaRocks Installation

View File

@@ -11,7 +11,6 @@ environment:
- LUA: "lua 5.1"
- LUA: "lua 5.2 --compat none"
- LUA: "lua 5.3 --compat none"
- LUA: "luajit 2.0"
- LUA: "luajit 2.1"
# Abuse this section so we can have a matrix with different Compiler versions
@@ -30,7 +29,7 @@ before_build:
- echo "Installing external deps"
build_script:
- luarocks make rockspecs/luafilesystem-cvs-3.rockspec
- luarocks make
before_test:

12
config
View File

@@ -3,21 +3,25 @@
# Default installation prefix
PREFIX=/usr/local
LUA_VERSION = 5.1
# System's libraries directory (where binary libraries are installed)
LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
LUA_LIBDIR= $(PREFIX)/lib/lua/$(LUA_VERSION)
# Lua includes directory
LUA_INC= $(PREFIX)/include
LUA_INC += -I$(PREFIX)/include
LUA_INC += -I/usr/include/lua$(LUA_VERSION) -I/usr/include/lua/$(LUA_VERSION)
# OS dependent
LIB_OPTION= -shared #for Linux
#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
LIBNAME= $T.so.$V
# Minimum runtime OS version on macOS
MACOSX_DEPLOYMENT_TARGET= 10.5
# Compilation directives
WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
INCS= -I$(LUA_INC)
INCS= $(LUA_INC)
CFLAGS= $(WARN) $(INCS)
CC= gcc

View File

@@ -1,14 +1,14 @@
LUA_VERSION= 5.1
# Installation directories
# System's libraries directory (where binary libraries are installed)
LUA_LIBDIR= "c:\lua5.1"
LUA_LIBDIR= "c:\lua$(LUA_VERSION)"
# Lua includes directory
LUA_INC= "c:\lua5.1\include"
LUA_INC= "c:\lua$(LUA_VERSION)\include"
# Lua library
LUA_LIB= "c:\lua5.1\lua5.1.lib"
LIBNAME= $T.dll
LUA_LIB= "c:\lua$(LUA_VERSION)\lua$(LUA_VERSION).lib"
# Compilation directives
WARN= /O2

View File

@@ -1,182 +1,179 @@
body {
margin-left: 1em;
margin-right: 1em;
font-family: arial, helvetica, geneva, sans-serif;
background-color:#ffffff; margin:0px;
color: #47555c;
font-size: 16px;
font-family: "Open Sans", sans-serif;
margin: 0;
padding: 0;
background: #eff4ff;
}
a:link { color: #008fee; }
a:visited { color: #008fee; }
a:hover { color: #22a7ff; }
h1 { font-size:26px; }
h2 { font-size:24px; }
h3 { font-size:18px; }
h4 { font-size:16px; }
hr {
height: 1px;
background: #c1cce4;
border: 0px;
margin: 20px 0;
}
code {
font-family: "Andale Mono", monospace;
font-family: "Open Sans Mono", "Andale Mono", monospace;
}
tt {
font-family: "Andale Mono", monospace;
font-family: "Open Sans Mono", "Andale Mono", monospace;
}
body, td, th { font-size: 11pt; }
h1, h2, h3, h4 { margin-left: 0em; }
textarea, pre, tt { font-size:10pt; }
body, td, th { color:#000000; }
small { font-size:0.85em; }
h1 { font-size:1.5em; }
h2 { font-size:1.25em; }
h3 { font-size:1.15em; }
h4 { font-size:1.06em; }
a:link { font-weight:bold; color: #004080; text-decoration: none; }
a:visited { font-weight:bold; color: #006699; text-decoration: none; }
a:link:hover { text-decoration:underline; }
hr { color:#cccccc }
img { border-width: 0px; }
h3 { padding-top: 1em; }
p { margin-left: 1em; }
p.name {
font-family: "Andale Mono", monospace;
padding-top: 1em;
margin-left: 0em;
body, td, th {
}
blockquote { margin-left: 3em; }
textarea, pre, tt {
font-family: "Open Sans Mono", "Andale Mono", monospace;
}
img {
border-width: 0px;
}
.example {
background-color: rgb(245, 245, 245);
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: silver;
border-right-color: silver;
border-bottom-color: silver;
border-left-color: silver;
padding: 1em;
margin-left: 1em;
margin-right: 1em;
font-family: "Andale Mono", monospace;
font-size: smaller;
background-color: #323744;
color: white;
font-size: 16px;
padding: 16px 24px;
border-radius: 2px;
}
hr {
margin-left: 0em;
background: #00007f;
border: 0px;
height: 1px;
div.header, div.footer {
}
ul { list-style-type: disc; }
#container {
}
table.index { border: 1px #00007f; }
table.index td { text-align: left; vertical-align: top; }
table.index ul { padding-top: 0em; margin-top: 0em; }
#product {
background-color: white;
padding: 10px;
height: 130px;
border-bottom: solid #d3dbec 1px;
}
table {
border: 1px solid black;
border-collapse: collapse;
#product big {
font-size: 42px;
}
#product strong {
font-weight: normal;
}
#product_logo {
float: right;
}
#product_name {
padding-top: 15px;
padding-left: 30px;
font-size: 42px;
font-weight: normal;
}
#product_description {
padding-left: 30px;
color: #757779;
}
#main {
background: #eff4ff;
margin: 0;
}
#navigation {
width: 100%;
background-color: rgb(44,62,103);
padding: 10px;
margin: 0;
}
#navigation h1 {
display: none;
}
#navigation a:hover {
text-decoration: underline;
}
#navigation ul li a {
color: rgb(136, 208, 255);
font-weight: bold;
text-decoration: none;
}
#navigation ul li li a {
color: rgb(136, 208, 255);
font-weight: normal;
text-decoration: none;
}
#navigation ul {
display: inline;
color: white;
padding: 0px;
padding-top: 10px;
padding-bottom: 10px;
}
#navigation li {
display: inline;
list-style-type: none;
padding-left: 5px;
padding-right: 5px;
}
#navigation li {
padding: 10px;
padding: 10px;
}
#navigation li li {
}
#navigation li:hover a {
color: rgb(166, 238, 255);
}
#content {
padding: 20px;
width: 800px;
margin-left: auto;
margin-right: auto;
}
th {
border: 1px solid black;
padding: 0.5em;
}
td {
border: 1px solid black;
padding: 0.5em;
}
div.header, div.footer { margin-left: 0em; }
#container {
margin-left: 1em;
margin-right: 1em;
background-color: #f0f0f0;
}
#product {
text-align: center;
border-bottom: 1px solid #cccccc;
background-color: #ffffff;
}
#product big {
font-size: 2em;
}
#product_logo {
}
#product_name {
}
#product_description {
}
#main {
background-color: #f0f0f0;
border-left: 2px solid #cccccc;
}
#navigation {
float: left;
width: 12em;
margin: 0;
vertical-align: top;
background-color: #f0f0f0;
overflow:visible;
}
#navigation h1 {
background-color:#e7e7e7;
font-size:1.1em;
color:#000000;
text-align:left;
margin:0px;
padding:0.2em;
border-top:1px solid #dddddd;
border-bottom:1px solid #dddddd;
}
#navigation ul {
font-size:1em;
list-style-type: none;
padding: 0;
margin: 1px;
}
#navigation li {
text-indent: -1em;
margin: 0em 0em 0em 0.5em;
display: block;
padding: 3px 0px 0px 12px;
}
#navigation li li a {
padding: 0px 3px 0px -1em;
}
#content {
margin-left: 12em;
padding: 1em;
border-left: 2px solid #cccccc;
border-right: 2px solid #cccccc;
background-color: #ffffff;
}
#about {
clear: both;
margin: 0;
display: none;
}
dl.reference {
background-color: white;
padding: 20px;
border: solid #d3dbec 1px;
}
dl.reference dt {
padding: 5px;
border-top: 2px solid #cccccc;
background-color: #ffffff;
padding-top: 25px;
color: #637bbc;
}
dl.reference dl dt {
padding-top: 5px;
color: #637383;
}
dl.reference dd {
}
@media print {

View File

@@ -70,17 +70,39 @@ the underlying directory structure and file attributes.</p>
<h2><a name="status"></a>Status</h2>
<p>Current version is 1.6.3. It works with Lua 5.1, 5.2 and 5.3.</p>
<p>Current version is 1.8.0. It works with Lua 5.1, 5.2, 5.3 and 5.4, and it runs on various
flavors of Unix (including Linux, BSDs, macOS) and Windows.</p>
<h2><a name="download"></a>Download</h2>
<p>LuaFileSystem source can be downloaded from its
<a href="http://github.com/keplerproject/luafilesystem">Github</a>
page.</p>
<p>LuaFileSystem can be installed using <a href="https://luarocks.org">LuaRocks</a>:
<pre class="example">
$ luarocks install luafilesystem
</pre>
<p>Its source can be found at its <a href="http://github.com/keplerproject/luafilesystem">Github</a> page.</p>
<h2><a name="history"></a>History</h2>
<dl class="history">
<dt><strong>Version 1.8.0</strong> [22/Apr/2020]</dt>
<dd><ul>
<li>Lua 5.4 support</li>
<li>lfs.link and lfs.symlinkattributes now work on Windows</li>
<li>MACOSX_DEPLOYMENT_TARGET is configurable in the Makefile</li>
<li>Fallback to _POSIX_PATH_MAX when MAXPATHLEN is not avaliable</li>
<li>Fixed memory leak in case of realloc failure</li>
</ul></dd>
<dt><strong>Version 1.7.0</strong> [15/Sep/2017]</dt>
<dd><ul>
<li>symlinkattributes function now provides 'target' field, containing name of the file that the symlink points to.</li>
<li>attributes, symlinkattributes, touch, mkdir, and rmdir functions now return system-dependent error code as the third value on error.</li>
<li>Fixed detection of closed files for Lua 5.2+ in setmode, lock, and unlock functions.</li>
<li>Fixed various compiler warnings.</li>
</ul></dd>
<dt><strong>Version 1.6.3</strong> [15/Jan/2015]</dt>
<dd><ul>
<li>Lua 5.3 support.</li>

View File

@@ -84,7 +84,7 @@ Ierusalimschy, Andr&eacute; Carregal and Tom&aacute;s Guisasola.
The implementation is not derived from licensed software.</p>
<hr/>
<p>Copyright &copy; 2003 Kepler Project.</p>
<p>Copyright &copy; 2003 - 2020 Kepler Project.</p>
<p>Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -102,15 +102,15 @@ LuaFileSystem offers the following functions:
</p>
<dl class="reference">
<dt><a name="attributes"></a><strong><code>lfs.attributes (filepath [, aname | atable])</code></strong></dt>
<dt><a name="attributes"></a><strong><code>lfs.attributes (filepath [, request_name | result_table])</code></strong></dt>
<dd>Returns a table with the file attributes corresponding to
<code>filepath</code> (or <code>nil</code> followed by an error message
<code>filepath</code> (or <code>nil</code> followed by an error message and a system-dependent error code
in case of error).
If the second optional argument is given and is a string, then only the value of the
named attribute is returned (this use is equivalent to
<code>lfs.attributes(filepath)[aname]</code>, but the table is not created
<code>lfs.attributes(filepath)[request_name]</code>, but the table is not created
and only one attribute is retrieved from the O.S.).
if a table is passed as the second argument, it is filled with attributes and returned instead of a new table.
if a table is passed as the second argument, it (<code>result_table</code>) is filled with attributes and returned instead of a new table.
The attributes are described as follows;
attribute <code>mode</code> is a string, all the others are numbers,
and the time related attributes use the same time reference of
@@ -177,7 +177,7 @@ LuaFileSystem offers the following functions:
Returns <code>true</code> in case of success or <code>nil</code> plus an
error string.</dd>
<dt><a name="chdir"></a><strong><code>lfs.lock_dir(path, [seconds_stale])</code></strong></dt>
<dt><a name="lock_dir"></a><strong><code>lfs.lock_dir(path, [seconds_stale])</code></strong></dt>
<dd>Creates a lockfile (called lockfile.lfs) in <code>path</code> if it does not
exist and returns the lock. If the lock already exists checks if
it's stale, using the second parameter (default for the second
@@ -187,7 +187,7 @@ LuaFileSystem offers the following functions:
particular, if the lock exists and is not stale it returns the
"File exists" message.</dd>
<dt><a name="getcwd"></a><strong><code>lfs.currentdir ()</code></strong></dt>
<dt><a name="currentdir"></a><strong><code>lfs.currentdir ()</code></strong></dt>
<dd>Returns a string with the current working directory or <code>nil</code>
plus an error string.</dd>
@@ -222,14 +222,14 @@ LuaFileSystem offers the following functions:
<dt><a name="mkdir"></a><strong><code>lfs.mkdir (dirname)</code></strong></dt>
<dd>Creates a new directory. The argument is the name of the new
directory.<br />
Returns <code>true</code> if the operation was successful;
in case of error, it returns <code>nil</code> plus an error string.
Returns <code>true</code> in case of success or <code>nil</code>, an error message and
a system-dependent error code in case of error.
</dd>
<dt><a name="rmdir"></a><strong><code>lfs.rmdir (dirname)</code></strong></dt>
<dd>Removes an existing directory. The argument is the name of the directory.<br />
Returns <code>true</code> if the operation was successful;
in case of error, it returns <code>nil</code> plus an error string.</dd>
Returns <code>true</code> in case of success or <code>nil</code>, an error message and
a system-dependent error code in case of error.
<dt><a name="setmode"></a><strong><code>lfs.setmode (file, mode)</code></strong></dt>
<dd>Sets the writing mode for a file. The mode string can be either <code>"binary"</code> or <code>"text"</code>.
@@ -239,9 +239,11 @@ LuaFileSystem offers the following functions:
setting the mode has no effect, and the mode is always returned as <code>binary</code>.
</dd>
<dt><a name="symlinkattributes"></a><strong><code>lfs.symlinkattributes (filepath [, aname])</code></strong></dt>
<dt><a name="symlinkattributes"></a><strong><code>lfs.symlinkattributes (filepath [, request_name])</code></strong></dt>
<dd>Identical to <a href="#attributes">lfs.attributes</a> except that
it obtains information about the link itself (not the file it refers to).
It also adds a <strong><code>target</code></strong> field, containing
the file name that the symlink points to.
On Windows this function does not yet support links, and is identical to
<code>lfs.attributes</code>.
</dd>
@@ -255,8 +257,8 @@ LuaFileSystem offers the following functions:
Lua standard function <code>os.time</code>).
If the modification time is omitted, the access time provided is used;
if both times are omitted, the current time is used.<br />
Returns <code>true</code> if the operation was successful;
in case of error, it returns <code>nil</code> plus an error string.
Returns <code>true</code> in case of success or <code>nil</code>, an error message and
a system-dependent error code in case of error.
</dd>
<dt><a name="unlock"></a><strong><code>lfs.unlock (filehandle[, start[, length]])</code></strong></dt>

View File

@@ -1,8 +1,7 @@
package = "LuaFileSystem"
version = "1.6.3-1"
package = "luafilesystem"
version = "scm-1"
source = {
url = "git://github.com/keplerproject/luafilesystem",
tag = "v_1_6_3",
url = "git://github.com/keplerproject/luafilesystem"
}
description = {
summary = "File System Library for the Lua Programming Language",
@@ -12,7 +11,7 @@ description = {
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]],
license = "MIT/X11",
license = "MIT/X11"
}
dependencies = {
"lua >= 5.1"
@@ -23,6 +22,7 @@ build = {
lfs = "src/lfs.c"
},
copy_directories = {
"doc", "tests"
"doc",
"tests"
}
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.3.0-1"
source = {
url = "http://luaforge.net/frs/download.php/2679/luafilesystem-1.3.0.tar.gz"
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "make",
build_variables = {
LUA_INC = "$(LUA_INCDIR)",
LIB_OPTION = "$(LIBFLAG)"
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.4.0-1"
source = {
url = "http://luaforge.net/frs/download.php/3158/luafilesystem-1.4.0.tar.gz"
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "make",
build_variables = {
LUA_INC = "$(LUA_INCDIR)",
LIB_OPTION = "$(LIBFLAG)"
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
}

View File

@@ -1,43 +0,0 @@
package = "LuaFileSystem"
version = "1.4.0-2"
source = {
url = "http://luaforge.net/frs/download.php/3158/luafilesystem-1.4.0.tar.gz"
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
platforms = {
unix = {
type = "make",
build_variables = {
LIB_OPTION = "$(LIBFLAG)",
CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
},
win32 = {
type = "make",
build_variables = {
LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib",
CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)",
LUA_DIR = "$(LUADIR)",
BIN_DIR = "$(BINDIR)"
}
}
}
}

View File

@@ -1,43 +0,0 @@
package = "LuaFileSystem"
version = "1.4.1-1"
source = {
url = "http://luaforge.net/frs/download.php/3345/luafilesystem-1.4.1.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
platforms = {
unix = {
type = "make",
build_variables = {
LIB_OPTION = "$(LIBFLAG)",
CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) $(STAT64)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
},
win32 = {
type = "make",
build_variables = {
LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib",
CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)",
LUA_DIR = "$(LUADIR)",
BIN_DIR = "$(BINDIR)"
}
}
}
}

View File

@@ -1,43 +0,0 @@
package = "LuaFileSystem"
version = "1.4.1rc1-1"
source = {
url = "http://luafilesystem.luaforge.net/luafilesystem-1.4.1rc1.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
platforms = {
unix = {
type = "make",
build_variables = {
LIB_OPTION = "$(LIBFLAG)",
CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) $(STAT64)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
},
win32 = {
type = "make",
build_variables = {
LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib",
CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)",
LUA_DIR = "$(LUADIR)",
BIN_DIR = "$(BINDIR)"
}
}
}
}

View File

@@ -1,26 +0,0 @@
package = "LuaFileSystem"
version = "1.4.2-1"
source = {
url = "http://luaforge.net/frs/download.php/3931/luafilesystem-1.4.2.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "module",
modules = { lfs = "src/lfs.c" }
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.5.0-1"
source = {
url = "http://cloud.github.com/downloads/keplerproject/luafilesystem/luafilesystem-1.5.0.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "module",
modules = { lfs = "src/lfs.c" },
copy_directories = { "doc", "tests" }
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.6.0-1"
source = {
url = "https://github.com/downloads/keplerproject/luafilesystem/luafilesystem-1.6.0.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = { lfs = "src/lfs.c" },
copy_directories = { "doc", "tests" }
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.6.1-1"
source = {
url = "https://github.com/downloads/keplerproject/luafilesystem/luafilesystem-1.6.1.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = { lfs = "src/lfs.c" },
copy_directories = { "doc", "tests" }
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "1.6.2-1"
source = {
url = "https://github.com/downloads/keplerproject/luafilesystem/luafilesystem-1.6.2.tar.gz",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = { lfs = "src/lfs.c" },
copy_directories = { "doc", "tests" }
}

View File

@@ -1,44 +0,0 @@
package = "LuaFileSystem"
version = "cvs-1"
source = {
url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/luafilesystem",
cvs_tag = "HEAD"
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
platforms = {
unix = {
type = "make",
build_variables = {
LIB_OPTION = "$(LIBFLAG)",
CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)"
}
},
win32 = {
type = "make",
build_variables = {
LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib",
CFLAGS = "$(CFLAGS) /I$(LUA_INCDIR)",
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)",
LUA_DIR = "$(LUADIR)",
BIN_DIR = "$(BINDIR)"
}
}
}
}

View File

@@ -1,26 +0,0 @@
package = "LuaFileSystem"
version = "cvs-2"
source = {
url = "git://github.com/keplerproject/luafilesystem.git",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "module",
modules = { lfs = "src/lfs.c" }
}

View File

@@ -1,27 +0,0 @@
package = "LuaFileSystem"
version = "cvs-3"
source = {
url = "git://github.com/keplerproject/luafilesystem.git",
}
description = {
summary = "File System Library for the Lua Programming Language",
detailed = [[
LuaFileSystem is a Lua library developed to complement the set of
functions related to file systems offered by the standard Lua
distribution. LuaFileSystem offers a portable way to access the
underlying directory structure and file attributes.
]]
}
dependencies = {
"lua >= 5.1, < 5.4"
}
build = {
type = "builtin",
modules = { lfs = "src/lfs.c" },
copy_directories = { "doc", "tests" }
}

1274
src/lfs.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
LIBRARY lfs.dll
VERSION 1.6
VERSION 1.8
EXPORTS
luaopen_lfs

View File

@@ -1,33 +1,34 @@
/*
** LuaFileSystem
** Copyright Kepler Project 2003 - 2016 (http://keplerproject.github.io/luafilesystem)
** Copyright Kepler Project 2003 - 2020
** (http://keplerproject.github.io/luafilesystem)
*/
/* Define 'chdir' for systems that do not implement it */
#ifdef NO_CHDIR
#define chdir(p) (-1)
#define chdir_error "Function 'chdir' not provided by system"
#define chdir(p) (-1)
#define chdir_error "Function 'chdir' not provided by system"
#else
#define chdir_error strerror(errno)
#define chdir_error strerror(errno)
#endif
#ifdef _WIN32
#define chdir(p) (_chdir(p))
#define getcwd(d, s) (_getcwd(d, s))
#define rmdir(p) (_rmdir(p))
#define LFS_EXPORT __declspec (dllexport)
#ifndef fileno
#define fileno(f) (_fileno(f))
#endif
#define chdir(p) (_chdir(p))
#define getcwd(d, s) (_getcwd(d, s))
#define rmdir(p) (_rmdir(p))
#define LFS_EXPORT __declspec (dllexport)
#ifndef fileno
#define fileno(f) (_fileno(f))
#endif
#else
#define LFS_EXPORT
#define LFS_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
LFS_EXPORT int luaopen_lfs (lua_State *L);
LFS_EXPORT int luaopen_lfs(lua_State * L);
#ifdef __cplusplus
}

View File

@@ -4,6 +4,8 @@ local tmp = "/tmp"
local sep = string.match (package.config, "[^\n]+")
local upper = ".."
local is_unix = package.config:sub(1,1) == "/"
local lfs = require"lfs"
print (lfs._VERSION)
@@ -60,6 +62,8 @@ if not attrib then
error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg)
end
local f = io.open(tmpfile, "w")
local data = "hello, file!"
f:write(data)
f:close()
io.write(".")
@@ -87,12 +91,42 @@ assert (new_att.modification == testdate1, "could not set modification time")
io.write(".")
io.flush()
-- Checking link (does not work on Windows)
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)
assert (lfs.symlinkattributes("_a_link_for_test_", "target") == tmpfile)
assert (lfs.symlinkattributes(tmpfile).mode == "file")
assert (lfs.link (tmpfile, "_a_hard_link_for_test_"))
assert (lfs.attributes (tmpfile, "nlink") == 2)
assert (lfs.symlinkattributes"_a_hard_link_for_test_".mode == "file")
local fd = io.open(tmpfile)
assert(fd:read("*a") == data)
fd:close()
fd = io.open("_a_link_for_test_")
assert(fd:read("*a") == data)
fd:close()
fd = io.open("_a_hard_link_for_test_")
assert(fd:read("*a") == data)
fd:close()
fd = io.open("_a_hard_link_for_test_", "w+")
local data2 = "write in hard link"
fd:write(data2)
fd:close()
fd = io.open(tmpfile)
assert(fd:read("*a") == data2)
fd:close()
if is_unix then
assert (lfs.attributes (tmpfile, "nlink") == 2)
end
assert (os.remove"_a_link_for_test_")
assert (os.remove"_a_hard_link_for_test_")
end
@@ -130,6 +164,17 @@ for key, value in pairs(attr) do
"lfs.attributes values not consistent")
end
-- Check that lfs.attributes accepts a table as second argument
local attr2 = {}
lfs.attributes(tmpfile, attr2)
for key, value in pairs(attr2) do
assert (value == lfs.attributes (tmpfile, key),
"lfs.attributes values with table argument not consistent")
end
-- Check that extra arguments are ignored
lfs.attributes(tmpfile, attr2, nil)
-- Remove new file and directory
assert (os.remove (tmpfile), "could not remove new file")
assert (lfs.rmdir (tmpdir), "could not remove new directory")
@@ -139,7 +184,10 @@ io.write(".")
io.flush()
-- Trying to 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")
local attr_ok, err, errno = lfs.attributes("this couldn't be an actual file")
assert(attr_ok == nil, "could get attributes of a non-existent file")
assert(type(err) == "string", "failed lfs.attributes did not return an error message")
assert(type(errno) == "number", "failed lfs.attributes did not return error code")
assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory")
io.write(".")