3 Commits

Author SHA1 Message Date
Hisham Muhammad
d68db4ca79 accept high-precision timestamps in lfs.touch 2021-01-23 15:49:05 -03:00
Hisham Muhammad
6adf412a25 return higher precision times in lfs.attributes 2021-01-23 15:49:05 -03:00
Hisham Muhammad
442fabb11a CI: add Mac build 2021-01-23 15:49:05 -03:00
19 changed files with 389 additions and 185 deletions

View File

@@ -1,78 +0,0 @@
name: ci
on:
pull_request:
push:
branches:
- master
jobs:
TestMatrix:
strategy:
matrix:
lua-version: ["5.4", "5.3", "5.2", "5.1", "luajit"]
os: ["ubuntu-latest"]
libflag: ["-shared --coverage"]
include:
- os: "macos-latest"
lua-version: "5.4"
libflag: "-bundle -undefined dynamic_lookup -all_load --coverage"
- os: "windows-latest"
toolchain: "msvc"
lua-version: "5.4"
- os: "windows-latest"
lua-version: "luajit"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Setup MSVC
# 'luarocks/gh-actions-lua' step requires msvc to build PUC-Rio Lua
# versions on Windows (LuaJIT will be built using MinGW/gcc).
if: ${{ matrix.toolchain == 'msvc' }}
uses: ilammy/msvc-dev-cmd@v1
- uses: luarocks/gh-actions-lua@master
with:
luaVersion: ${{ matrix.lua-version }}
- uses: luarocks/gh-actions-luarocks@master
- name: Prep luacov
run: |
luarocks install luacov
- name: Prep luacov-coveralls
# TODO Windows coverage
if: ${{ matrix.os != 'windows-latest' }}
run: |
pip install --user cpp-coveralls
# install luacov-coveralls, but avoid installing luafilesystem
luarocks install lua-path
luarocks install dkjson
luarocks install luacov-coveralls --server=https://luarocks.org/dev --deps-mode=none
- name: Unix Build
if: ${{ matrix.os != 'windows-latest' }}
run: |
luarocks make CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="${{ matrix.libflag }}"
- name: Windows Build
# TODO Windows coverage
if: ${{ matrix.os == 'windows-latest' }}
run: |
luarocks make
- name: Test
run: |
lua -lluacov tests/test.lua
- name: Coverage
# TODO Windows coverage
if: ${{ matrix.os != 'windows-latest' }}
run: |
export MY_PYTHON_VER=$(python -c 'import sys; print(".".join(sys.version.split(".")[0:2]))')
export PATH="/Users/runner/Library/Python/$MY_PYTHON_VER/bin:$PATH"
coveralls -b . -i src --dump c.report.json
luacov-coveralls -j c.report.json -v -t ${{ secrets.GITHUB_TOKEN }}

53
.travis.yml Normal file
View File

@@ -0,0 +1,53 @@
language: generic
sudo: false
jobs:
- os: linux
env:
- LUA="lua 5.1"
LIBFLAG="-shared --coverage"
- os: linux
env:
- LUA="lua 5.2"
LIBFLAG="-shared --coverage"
- os: linux
env:
- LUA="lua 5.3"
LIBFLAG="-shared --coverage"
- os: linux
env:
- LUA="lua 5.4"
LIBFLAG="-shared --coverage"
- os: linux
env:
- LUA="luajit 2.1"
LIBFLAG="-shared --coverage"
- os: osx
env:
- LUA="lua 5.1"
LIBFLAG="-bundle -undefined dynamic_lookup -all_load --coverage"
before_install:
- pip install cpp-coveralls hererocks
- hererocks env --$LUA --luarocks latest
- export PATH="$PWD/env/bin:$PATH"
- luarocks install lua-path
- luarocks install dkjson
- luarocks install luacov
# install luacov-coveralls, but avoid installing luafilesystem
- luarocks install luacov-coveralls --server=https://luarocks.org/dev --deps-mode=none
install:
- luarocks make CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="$LIBFLAG"
script:
- lua -lluacov tests/test.lua
after_success:
- coveralls -b . -i src --dump c.report.json
- luacov-coveralls -j c.report.json -v
notifications:
email:
on_success: change
on_failure: always

View File

@@ -1,5 +1,4 @@
Copyright © 2003-2010 Kepler Project.
Copyright © 2010-2022 The LuaFileSystem authors.
Copyright © 2003-2014 Kepler Project.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -1,11 +1,13 @@
[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://github.com/lunarmodules/luafilesystem/actions/workflows/ci.yml/badge.svg)](https://github.com/lunarmodules/luafilesystem/actions)
[![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/lunarmodules/luafilesystem/badge.png)](https://coveralls.io/r/lunarmodules/luafilesystem)
[![Coverage Status](https://coveralls.io/repos/keplerproject/luafilesystem/badge.png)](https://coveralls.io/r/keplerproject/luafilesystem)
# LuaFileSystem - File System Library for Lua
https://lunarmodules.github.io/luafilesystem
Copyright 2003-2020 Kepler Project
https://keplerproject.github.io/luafilesystem
# Description
@@ -23,4 +25,4 @@ luarocks install luafilesystem
# Documentation
Please check the at `docs/` for more information, also available at the [project website](https://lunarmodules.github.io/luafilesystem).
Please check the documentation at doc/us/ for more information.

View File

@@ -1,25 +1,17 @@
version: 0.0.1.{build}-test
# Use default image unless needed
#os:
#- Windows Server 2012 R2
shallow_clone: true
matrix:
fast_finish: true
environment:
matrix:
- LUAT: "lua"
LUAV: "5.1"
- LUAT: "lua"
LUAV: "5.2"
HEREROCKS_FLAGS: "--compat none"
- LUAT: "lua"
LUAV: "5.3"
HEREROCKS_FLAGS: "--compat none"
- LUAT: "lua"
LUAV: "5.4"
HEREROCKS_FLAGS: "--compat none"
- LUAT: "luajit"
LUAV: "2.1"
- LUA: "lua 5.1"
- LUA: "lua 5.2 --compat none"
- LUA: "lua 5.3 --compat none"
- LUA: "luajit 2.1"
# Abuse this section so we can have a matrix with different Compiler versions
configuration:
@@ -27,14 +19,14 @@ configuration:
- vs_32
- vs_64
install:
- set PATH=%CD%\env\bin;C:\Python27\Scripts;C:\MinGW\bin;%PATH%
- pip install hererocks
- hererocks env --%LUA% --target %configuration% --luarocks latest
before_build:
- set PATH=C:\MinGW\bin;%PATH%
- set PATH=C:\Python37;C:\Python37\Scripts;%PATH% # Add directory containing 'pip' to PATH
- IF NOT EXIST lua_install-%LUAV%\bin\activate.bat ( pip install --upgrade certifi )
- FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "import certifi;print(certifi.where())"`) DO ( SET SSL_CERT_FILE=%%F )
- IF NOT EXIST lua_install-%LUAV%\bin\activate.bat ( pip install hererocks )
- IF NOT EXIST lua_install-%LUAV%\bin\activate.bat ( hererocks lua_install-%LUAV% --%LUAT% %LUAV% %HEREROCKS_FLAGS% --luarocks latest --target=%configuration% )
- call lua_install-%LUAV%\bin\activate
# @todo
- echo "Installing external deps"
build_script:
- luarocks make
@@ -45,9 +37,5 @@ test_script:
- echo "Testing..."
- lua tests/test.lua
cache:
- lua_install-5.4
- lua_install-5.3
- lua_install-5.2
- lua_install-5.1
- lua_install-2.1
after_test:
# @todo

View File

@@ -13,7 +13,7 @@
<div id="product">
<div id="product_logo">
<a href="http://lunarmodules.github.io/luafilesystem">
<a href="http://keplerproject.github.io/luafilesystem">
<img alt="LuaFileSystem" src="luafilesystem.png"/>
</a>
</div>
@@ -44,10 +44,10 @@
</ul>
</li>
<li><strong>Examples</strong></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Project</a>
<li><a href="https://github.com/keplerproject/luafilesystem">Project</a>
<ul>
<li><a href="https://github.com/lunarmodules/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Git</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem">Git</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>

View File

@@ -13,7 +13,7 @@
<div id="product">
<div id="product_logo">
<a href="http://lunarmodules.github.io/luafilesystem">
<a href="http://keplerproject.github.io/luafilesystem">
<img alt="LuaFileSystem" src="luafilesystem.png"/>
</a>
</div>
@@ -44,10 +44,10 @@
</ul>
</li>
<li><a href="examples.html">Examples</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Project</a>
<li><a href="https://github.com/keplerproject/luafilesystem">Project</a>
<ul>
<li><a href="https://github.com/lunarmodules/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Git</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem">Git</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>
@@ -70,7 +70,7 @@ the underlying directory structure and file attributes.</p>
<h2><a name="status"></a>Status</h2>
<p>Current version is 1.9.0. It works with Lua 5.1 to Lua 5.5, and it runs on various
<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>
@@ -81,18 +81,11 @@ flavors of Unix (including Linux, BSDs, macOS) and Windows.</p>
$ luarocks install luafilesystem
</pre>
<p>Its source can be found at its <a href="http://github.com/lunarmodules/luafilesystem">GitHub</a> page.</p>
<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.9.0</strong> [28/Dec/2025]</dt>
<dd><ul>
<li>Lua 5.5 support</li>
<li>Fixed some compiler warnings</li>
<li>Assorted improvements for Windows</li>
</ul></dd>
<dt><strong>Version 1.8.0</strong> [22/Apr/2020]</dt>
<dd><ul>
<li>Lua 5.4 support</li>
@@ -217,11 +210,10 @@ $ luarocks install luafilesystem
<h2><a name="credits"></a>Credits</h2>
<p>The LuaFileSystem library was originally designed and
implemented by Roberto Ierusalimschy, Andr&eacute; Carregal and
Tom&aacute;s Guisasola. It was then maintained by F&aacute;bio
Mascarenhas for several years and has since been maintained
by many contributors -- see the Git history for detailed credits.</p>
<p>LuaFileSystem was designed by Roberto Ierusalimschy,
Andr&eacute; Carregal and Tom&aacute;s Guisasola as part of the
<a href="https://github.com/keplerproject">Kepler Project</a>,
which holds its copyright. LuaFileSystem is currently maintained by F&aacute;bio Mascarenhas.</p>
</div> <!-- id="content" -->

View File

@@ -13,7 +13,7 @@
<div id="product">
<div id="product_logo">
<a href="http://lunarmodules.github.io/luafilesystem">
<a href="http://keplerproject.github.io/luafilesystem">
<img alt="LuaFileSystem" src="luafilesystem.png"/>
</a>
</div>
@@ -44,10 +44,10 @@
</ul>
</li>
<li><a href="examples.html">Examples</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Project</a>
<li><a href="https://github.com/keplerproject/luafilesystem">Project</a>
<ul>
<li><a href="https://github.com/lunarmodules/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Git</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem">Git</a></li>
</ul>
</li>
<li><strong>License</strong></li>
@@ -58,21 +58,33 @@
<h1>License</h1>
<p>
LuaFileSystem is free software: it can be used for both academic
and commercial purposes at absolutely no cost. There are no
royalties or GNU-like "copyleft" restrictions. LuaFileSystem
qualifies as
<a href="http://www.opensource.org/docs/definition.html">Open Source</a>
software.
Its licenses are compatible with
<a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.
LuaFileSystem is not in the public domain and the
<a href="https://github.com/keplerproject">Kepler Project</a>
keep its copyright.
The legal details are below.
</p>
<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.
The only requirement is that if you do use LuaFileSystem, then you
should give us credit by including the appropriate copyright notice
somewhere in your product or its documentation.</p>
<p>The LuaFileSystem library was originally designed and
implemented by Roberto Ierusalimschy, Andr&eacute; Carregal and
Tom&aacute;s Guisasola, and has since been maintained over the years
by many people -- see the Git history for detailed credits.
The implementation is not derived from any other licensed software.</p>
<p>The LuaFileSystem library is designed and implemented by Roberto
Ierusalimschy, Andr&eacute; Carregal and Tom&aacute;s Guisasola.
The implementation is not derived from licensed software.</p>
<hr/>
<p>Copyright &copy; 2003 - 2010 Kepler Project.</p>
<p>Copyright &copy; 2010 - 2022 The LuaFileSystem authors.</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

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -13,7 +13,7 @@
<div id="product">
<div id="product_logo">
<a href="http://lunarmodules.github.io/luafilesystem">
<a href="http://keplerproject.github.io/luafilesystem">
<img alt="LuaFileSystem" src="luafilesystem.png"/>
</a>
</div>
@@ -44,10 +44,10 @@
</ul>
</li>
<li><a href="examples.html">Examples</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Project</a>
<li><a href="https://github.com/keplerproject/luafilesystem">Project</a>
<ul>
<li><a href="https://github.com/lunarmodules/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/lunarmodules/luafilesystem">Git</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li>
<li><a href="https://github.com/keplerproject/luafilesystem">Git</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>

View File

@@ -1,7 +1,7 @@
package = "luafilesystem"
version = "scm-1"
source = {
url = "git+https://github.com/lunarmodules/luafilesystem"
url = "git://github.com/keplerproject/luafilesystem"
}
description = {
summary = "File System Library for the Lua Programming Language",
@@ -22,7 +22,7 @@ build = {
lfs = "src/lfs.c"
},
copy_directories = {
"docs",
"doc",
"tests"
}
}

109
src/lfs.c
View File

@@ -1,10 +1,23 @@
/*
** LuaFileSystem
** File system manipulation library
** Copyright Kepler Project 2003 - 2020
** (http://keplerproject.github.io/luafilesystem)
**
** Copyright (C) 2003-2010 Kepler Project.
** Copyright (C) 2010-2022 The LuaFileSystem authors.
** (http://lunarmodules.github.io/luafilesystem)
** File system manipulation library.
** This library offers these functions:
** lfs.attributes (filepath [, attributename | attributetable])
** lfs.chdir (path)
** lfs.currentdir ()
** lfs.dir (path)
** lfs.link (old, new[, symlink])
** lfs.lock (fh, mode)
** lfs.lock_dir (path)
** lfs.mkdir (path)
** lfs.rmdir (path)
** lfs.setmode (filepath, mode)
** lfs.symlinkattributes (filepath [, attributename])
** lfs.touch (filepath [, atime [, mtime]])
** lfs.unlock (fh)
*/
#ifndef LFS_DO_NOT_USE_LARGE_FILE
@@ -74,7 +87,7 @@
#include "lfs.h"
#define LFS_VERSION "1.9.0"
#define LFS_VERSION "1.8.0"
#define LFS_LIBNAME "lfs"
#if LUA_VERSION_NUM >= 503 /* Lua 5.3+ */
@@ -159,6 +172,15 @@ typedef struct dir_data {
#endif
#if _POSIX_VERSION >= 200809L
#define UTIME_FUNC(dirp, name, utb) utimensat(dirp ? dirfd(dirp) : 0, name, utb, 0)
#define UTIME_STRUCT struct timespec
#else
#define UTIME_FUNC(dirp, name, utb) utime(name, utb)
#define UTIME_STRUCT struct utimbuf
#endif
#ifdef _WIN32
#define lfs_mkdir _mkdir
#else
@@ -168,7 +190,7 @@ typedef struct dir_data {
#ifdef _WIN32
static int lfs_win32_pusherror(lua_State * L)
int lfs_win32_pusherror(lua_State * L)
{
int en = GetLastError();
lua_pushnil(L);
@@ -181,7 +203,7 @@ static int lfs_win32_pusherror(lua_State * L)
#define TICKS_PER_SECOND 10000000
#define EPOCH_DIFFERENCE 11644473600LL
static time_t windowsToUnixTime(FILETIME ft)
time_t windowsToUnixTime(FILETIME ft)
{
ULARGE_INTEGER uli;
uli.LowPart = ft.dwLowDateTime;
@@ -189,7 +211,7 @@ static time_t windowsToUnixTime(FILETIME ft)
return (time_t) (uli.QuadPart / TICKS_PER_SECOND - EPOCH_DIFFERENCE);
}
static int lfs_win32_lstat(const char *path, STAT_STRUCT * buffer)
int lfs_win32_lstat(const char *path, STAT_STRUCT * buffer)
{
WIN32_FILE_ATTRIBUTE_DATA win32buffer;
if (GetFileAttributesEx(path, GetFileExInfoStandard, &win32buffer)) {
@@ -275,13 +297,13 @@ static int get_dir(lua_State * L)
size_t size = LFS_MAXPATHLEN; /* initial buffer size */
int result;
while (1) {
char *path2 = (char *)realloc(path, size);
char *path2 = realloc(path, size);
if (!path2) { /* failed to allocate */
result = pusherror(L, "get_dir realloc() failed");
break;
}
path = path2;
if (getcwd(path, (int)size) != NULL) {
if (getcwd(path, size) != NULL) {
/* success, push the path to the Lua stack */
lua_pushstring(L, path);
result = 1;
@@ -311,7 +333,7 @@ static FILE *check_file(lua_State * L, int idx, const char *funcname)
return 0;
} else
return *fh;
#elif LUA_VERSION_NUM >= 502 && LUA_VERSION_NUM <= 505
#elif LUA_VERSION_NUM >= 502 && LUA_VERSION_NUM <= 504
luaL_Stream *fh = (luaL_Stream *) luaL_checkudata(L, idx, "FILE*");
if (fh->closef == 0 || fh->f == NULL) {
luaL_error(L, "%s: closed file", funcname);
@@ -807,17 +829,39 @@ static const char *mode2string(mode_t mode)
static int file_utime(lua_State * L)
{
const char *file = luaL_checkstring(L, 1);
struct utimbuf utb, *buf;
UTIME_STRUCT utb[2];
UTIME_STRUCT *buf;
#ifndef _WIN32
DIR* dirp = NULL;
#endif
if (lua_gettop(L) == 1) /* set to current date/time */
buf = NULL;
else {
utb.actime = (time_t) luaL_optnumber(L, 2, 0);
utb.modtime = (time_t) luaL_optinteger(L, 3, utb.actime);
buf = &utb;
#if _POSIX_VERSION >= 200809L
lua_Number acctime = luaL_optnumber(L, 2, 0);
lua_Number modtime = luaL_optnumber(L, 3, acctime);
utb[0].tv_sec = acctime;
utb[0].tv_nsec = (acctime - utb[0].tv_sec) * 1000000000;
utb[1].tv_sec = modtime;
utb[1].tv_nsec = (modtime - utb[1].tv_sec) * 1000000000;
if (file[0] != '/') {
dirp = opendir(".");
}
#else
utb[0].actime = (time_t) luaL_optnumber(L, 2, 0);
utb[0].modtime = (time_t) luaL_optnumber(L, 3, utb[0].actime);
#endif
buf = utb;
}
return pushresult(L, utime(file, buf), NULL);
int res = UTIME_FUNC(dirp, file, buf);
#ifndef _WIN32
if (dirp) {
closedir(dirp);
}
#endif
return pushresult(L, res, NULL);
}
@@ -863,22 +907,37 @@ static void push_st_rdev(lua_State * L, STAT_STRUCT * info)
lua_pushinteger(L, (lua_Integer) info->st_rdev);
}
#define push_stat_timespec(field) \
lua_pushnumber(L, info->FIELDNAME(field).tv_sec \
+ info->FIELDNAME(field).tv_nsec / 1000000000.0)
#if _POSIX_VERSION >= 200809L
#define FIELDNAME(field) field
#define push_stat_time(field) push_stat_timespec(field)
#elif __APPLE__
#define FIELDNAME(field) field ## espec
#define push_stat_time(field) push_stat_timespec(field)
#else
#define FIELDNAME(field) field ## e
#define push_stat_time(field) lua_pushinteger(L, info->FIELDNAME(field))
#endif
/* time of last access */
static void push_st_atime(lua_State * L, STAT_STRUCT * info)
{
lua_pushinteger(L, (lua_Integer) info->st_atime);
push_stat_time(st_atim);
}
/* time of last data modification */
static void push_st_mtime(lua_State * L, STAT_STRUCT * info)
{
lua_pushinteger(L, (lua_Integer) info->st_mtime);
push_stat_time(st_mtim);
}
/* time of last file status change */
static void push_st_ctime(lua_State * L, STAT_STRUCT * info)
{
lua_pushinteger(L, (lua_Integer) info->st_ctime);
push_stat_time(st_ctim);
}
/* file size, in bytes */
@@ -1062,18 +1121,18 @@ static int push_link_target(lua_State * L)
}
#endif
char *target = NULL;
int tsize = 0, size = 256; /* size = initial buffer capacity */
int tsize, size = 256; /* size = initial buffer capacity */
int ok = 0;
while (!ok) {
char *target2 = (char *)realloc(target, size);
char *target2 = realloc(target, size);
if (!target2) { /* failed to allocate */
break;
}
target = target2;
#ifdef _WIN32
tsize = (int)GetFinalPathNameByHandle(h, target, size, FILE_NAME_OPENED);
tsize = GetFinalPathNameByHandle(h, target, size, FILE_NAME_OPENED);
#else
tsize = (int)readlink(file, target, size);
tsize = readlink(file, target, size);
#endif
if (tsize < 0) { /* a readlink() error occurred */
break;
@@ -1081,7 +1140,7 @@ static int push_link_target(lua_State * L)
if (tsize < size) {
#ifdef _WIN32
if (tsize > 4 && strncmp(target, "\\\\?\\", 4) == 0) {
memmove(target, target + 4, tsize - 3);
memmove_s(target, tsize - 3, target + 4, tsize - 3);
tsize -= 4;
}
#endif
@@ -1128,6 +1187,8 @@ static int link_info(lua_State * L)
*/
static void set_info(lua_State * L)
{
lua_pushliteral(L, "Copyright (C) 2003-2017 Kepler Project");
lua_setfield(L, -2, "_COPYRIGHT");
lua_pushliteral(L,
"LuaFileSystem is a Lua library developed to complement "
"the set of functions related to file systems offered by "

View File

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

View File

@@ -1,10 +1,7 @@
/*
** LuaFileSystem
** File system manipulation library
**
** Copyright (C) 2003-2010 Kepler Project.
** Copyright (C) 2010-2022 The LuaFileSystem authors.
** (http://lunarmodules.github.io/luafilesystem)
** Copyright Kepler Project 2003 - 2020
** (http://keplerproject.github.io/luafilesystem)
*/
/* Define 'chdir' for systems that do not implement it */

View File

@@ -79,6 +79,19 @@ assert (new_att.modification == testdate, "could not set modification time")
io.write(".")
io.flush()
-- High-precision attributes
local testdate_hi = os.time({ year = 2021, day = 1, month = 23, hour=0}) + 0.5555
assert (lfs.touch (tmpfile, testdate_hi))
local new_att_hi = assert (lfs.attributes (tmpfile))
if new_att_hi.modification ~= testdate_hi then
io.write("\n")
io.write("warning: no support for high-precision timestamps\n")
io.flush()
end
io.write(".")
io.flush()
-- Change access and modification time
local testdate1 = os.time({ year = 2007, day = 10, month = 2, hour=0})
local testdate2 = os.time({ year = 2007, day = 11, month = 2, hour=0})
@@ -151,8 +164,8 @@ io.flush()
-- Restore access time to current value
assert (lfs.touch (tmpfile, attrib.access, attrib.modification))
new_att = assert (lfs.attributes (tmpfile))
assert (new_att.access == attrib.access)
assert (new_att.modification == attrib.modification)
assert (new_att.access - attrib.access < 1)
assert (new_att.modification - attrib.modification < 1)
io.write(".")
io.flush()
@@ -194,7 +207,7 @@ io.write(".")
io.flush()
-- Stressing directory iterator
count = 0
local count = 0
for i = 1, 4000 do
for file in lfs.dir (tmp) do
count = count + 1

5
vc6/lfs.def Normal file
View File

@@ -0,0 +1,5 @@
LIBRARY lfs.dll
DESCRIPTION "LuaFileSystem"
VERSION 1.2
EXPORTS
luaopen_lfs

33
vc6/luafilesystem.dsw Normal file
View File

@@ -0,0 +1,33 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "luafilesystem_dll"=.\luafilesystem_dll.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
luafilesystem
..
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

127
vc6/luafilesystem_dll.dsp Normal file
View File

@@ -0,0 +1,127 @@
# Microsoft Developer Studio Project File - Name="luafilesystem_dll" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=luafilesystem_dll - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "luafilesystem_dll.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "luafilesystem_dll.mak" CFG="luafilesystem_dll - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "luafilesystem_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "luafilesystem_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "luafilesystem_dll"
# PROP Scc_LocalPath ".."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "luafilesystem_dll - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../lib/vc6"
# PROP Intermediate_Dir "luafilesystem_dll/Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAFILESYSTEM_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAFILESYSTEM_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x416 /d "NDEBUG"
# ADD RSC /l 0x416 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 lua50.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../bin/vc6/lfs.dll" /libpath:"../../external-src/lua50/lib/dll"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=cd ../bin/vc6 zip.exe luafilesystem-1.2-win32.zip lfs.dll
# End Special Build Tool
!ELSEIF "$(CFG)" == "luafilesystem_dll - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../lib/vc6"
# PROP Intermediate_Dir "luafilesystem_dll/Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAFILESYSTEM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAFILESYSTEM_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x416 /d "_DEBUG"
# ADD RSC /l 0x416 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 lua50.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../bin/vc6/lfsd.dll" /pdbtype:sept /libpath:"../../external-src/lua50/lib/dll"
!ENDIF
# Begin Target
# Name "luafilesystem_dll - Win32 Release"
# Name "luafilesystem_dll - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE="..\..\compat\src\compat-5.1.c"
# End Source File
# Begin Source File
SOURCE=..\src\lfs.c
# End Source File
# Begin Source File
SOURCE=.\lfs.def
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE="..\..\compat\src\compat-5.1.h"
# End Source File
# Begin Source File
SOURCE=..\src\lfs.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project