commit 8332f1ab9ef64d1c8faab97d31a026576490b510 Author: Fabio Mascarenhas Date: Tue Oct 20 19:03:43 2009 -0200 first pages commit for luafilesystem diff --git a/examples.html b/examples.html new file mode 100644 index 0000000..746df62 --- /dev/null +++ b/examples.html @@ -0,0 +1,103 @@ + + + + LuaFileSystem + + + + + + +
+ +
+ +
LuaFileSystem
+
File System Library for the Lua Programming Language
+
+ +
+ + + +
+ +

Examples

+ +

Directory iterator

+ +

The following example iterates over a directory and recursively lists the +attributes for each file inside it.

+ +
+require"lfs"
+
+function attrdir (path)
+    for file in lfs.dir(path) do
+        if file ~= "." and file ~= ".." then
+            local f = path..'/'..file
+            print ("\t "..f)
+            local attr = lfs.attributes (f)
+            assert (type(attr) == "table")
+            if attr.mode == "directory" then
+                attrdir (f)
+            else
+                for name, value in pairs(attr) do
+                    print (name, value)
+                end
+            end
+        end
+    end
+end
+
+attrdir (".")
+
+ +
+ +
+ +
+

Valid XHTML 1.0!

+

$Id: examples.html,v 1.8 2007/12/14 15:28:04 carregal Exp $

+
+ +
+ + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..43edefc --- /dev/null +++ b/index.html @@ -0,0 +1,192 @@ + + + + LuaFileSystem + + + + + + +
+ +
+ +
LuaFileSystem
+
File System Library for the Lua Programming Language
+
+ +
+ + + +
+ +

Overview

+ +

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.

+ +

Status

+ +

Current version is 1.5.0. It was developed for Lua 5.1.

+ +

Download

+ +

LuaFileSystem source can be downloaded from its +Github +page.

+ +

History

+ +
+
Version 1.5.0 [20/Oct/2009]
+
  • Added explicit next and close methods to second return value of lfs.dir +(the directory object), for explicit iteration or explicit closing.
  • +
  • Added directory locking via lfs.lock_dir function (see the manual).
  • +
    Version 1.4.2 [03/Feb/2009]
    +
    +
      +
    • fixed bug [#13198] + lfs.attributes(filename, 'size') overflow on files > 2 Gb again (bug report and patch by KUBO Takehiro).
    • +
    • fixed bug [#39794] + Compile error on Solaris 10 (bug report and patch by Aaron B).
    • +
    • fixed compilation problems with Borland C.
    • +
    +
    + +
    Version 1.4.1 [07/May/2008]
    +
    +
      +
    • documentation review
    • +
    • fixed Windows compilation issues
    • +
    • fixed bug in the Windows tests (patch by Shmuel Zeigerman)
    • +
    • fixed bug [#2185] + lfs.attributes(filename, 'size') overflow on files > 2 Gb +
    • +
    +
    + +
    Version 1.4.0 [13/Feb/2008]
    +
    +
      +
    • added function + lfs.setmode + (works only in Windows systems).
    • +
    • lfs.attributes + raises an error if attribute does not exist
    • +
    +
    + +
    Version 1.3.0 [26/Oct/2007]
    +
    + +
    + +
    Version 1.2.1 [08/May/2007]
    +
    +
      +
    • compatible only with Lua 5.1 (Lua 5.0 support was dropped)
    • +
    +
    + +
    Version 1.2 [15/Mar/2006]
    +
    + +
    + +
    Version 1.1 [30/May/2005]
    +
    + +
    + +
    Version 1.0 [21/Jan/2005]
    +
    + +
    Version 1.0 Beta [10/Nov/2004]
    +
    +
    + +

    Credits

    + +

    LuaFileSystem was designed by Roberto Ierusalimschy, +André Carregal and Tomás Guisasola as part of the +Kepler Project, +which holds its copyright. LuaFileSystem is currently maintained by Fábio Mascarenhas.

    + +

    Contact us

    + +

    For more information please +contact us. +Comments are welcome!

    + +

    You can also reach other Kepler developers and users on the Kepler Project +mailing list.

    + +
    + +
    + +
    +

    Valid XHTML 1.0!

    +

    $Id: index.html,v 1.44 2009/02/04 21:21:33 carregal Exp $

    +
    + +
    + + + diff --git a/license.html b/license.html new file mode 100644 index 0000000..4ecad4b --- /dev/null +++ b/license.html @@ -0,0 +1,122 @@ + + + + LuaFileSystem + + + + + + +
    + +
    + +
    LuaFileSystem
    +
    File System Library for the Lua Programming Language
    +
    + +
    + + + +
    + +

    License

    + +

    +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 +Open Source +software. +Its licenses are compatible with +GPL. +LuaFileSystem is not in the public domain and the +Kepler Project +keep its copyright. +The legal details are below. +

    + +

    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.

    + +

    The LuaFileSystem library is designed and implemented by Roberto +Ierusalimschy, André Carregal and Tomás Guisasola. +The implementation is not derived from licensed software.

    + +
    +

    Copyright © 2003 Kepler Project.

    + +

    Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

    + +

    The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

    + +

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.

    + +
    + +
    + +
    +

    Valid XHTML 1.0!

    +

    $Id: license.html,v 1.13 2008/02/11 22:42:21 carregal Exp $

    +
    + +
    + + + diff --git a/luafilesystem.png b/luafilesystem.png new file mode 100644 index 0000000..e1dd8c6 Binary files /dev/null and b/luafilesystem.png differ diff --git a/manual.html b/manual.html new file mode 100644 index 0000000..1409c40 --- /dev/null +++ b/manual.html @@ -0,0 +1,271 @@ + + + + LuaFileSystem + + + + + + +
    + +
    + +
    LuaFileSystem
    +
    File System Library for the Lua Programming Language
    +
    + +
    + + + +
    + +

    Introduction

    + +

    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.

    + +

    Building

    + +

    +LuaFileSystem should be built with Lua 5.1 so the language library +and header files for the target version must be installed properly. +

    + +

    +LuaFileSystem offers a Makefile and a separate configuration file, +config, +which should be edited to suit your installation before running +make. +The file has some definitions like paths to the external libraries, +compiler options and the like. +

    + +

    On Windows, the C runtime used to compile LuaFileSystem must be the same +runtime that Lua uses, or some LuaFileSystem functions will not work.

    + +

    Installation

    + +

    The easiest way to install LuaFileSystem is to use LuaRocks:

    + +
    +luarocks install luafilesystem
    +
    + +

    If you prefer to install LuaFileSystem manually, the compiled binary should be copied to a directory in your +C path.

    + +

    Reference

    + +

    +LuaFileSystem offers the following functions: +

    + +
    +
    lfs.attributes (filepath [, aname])
    +
    Returns a table with the file attributes corresponding to + filepath (or nil followed by an error message + in case of error). + If the second optional argument is given, then only the value of the + named attribute is returned (this use is equivalent to + lfs.attributes(filepath).aname, but the table is not created + and only one attribute is retrieved from the O.S.). + The attributes are described as follows; + attribute mode is a string, all the others are numbers, + and the time related attributes use the same time reference of + os.time: +
    +
    dev
    +
    on Unix systems, this represents the device that the inode resides on. On Windows systems, + represents the drive number of the disk containing the file
    + +
    ino
    +
    on Unix systems, this represents the inode number. On Windows systems this has no meaning
    + +
    mode
    +
    string representing the associated protection mode (the values could be + file, directory, link, socket, + named pipe, char device, block device or + other)
    + +
    nlink
    +
    number of hard links to the file
    + +
    uid
    +
    user-id of owner (Unix only, always 0 on Windows)
    + +
    gid
    +
    group-id of owner (Unix only, always 0 on Windows)
    + +
    rdev
    +
    on Unix systems, represents the device type, for special file inodes. + On Windows systems represents the same as dev
    + +
    access
    +
    time of last access
    + +
    modification
    +
    time of last data modification
    + +
    change
    +
    time of last file status change
    + +
    size
    +
    file size, in bytes
    + +
    blocks
    +
    block allocated for file; (Unix only)
    + +
    blksize
    +
    optimal file system I/O blocksize; (Unix only)
    +
    + This function uses stat internally thus if the given + filepath is a symbolic link, it is followed (if it points to + another link the chain is followed recursively) and the information + is about the file it refers to. + To obtain information about the link itself, see function + lfs.symlinkattributes. +
    + +
    lfs.chdir (path)
    +
    Changes the current working directory to the given + path.
    + Returns true in case of success or nil plus an + error string.
    + +
    lfs.lock_dir(path, [seconds_stale])
    +
    Creates a lockfile (called lockfile.lfs) in path if it does not + exist and returns the lock. If the lock already exists checks it + it's stale, using the second parameter (default for the second + parameter is INT_MAX, which in practice means the lock will never + be stale. To free the the lock call lock:free().
    + In case of any errors it returns nil and the error message. In + particular, if the lock exists and is not stale it returns the + "File exists" message.
    + +
    lfs.currentdir ()
    +
    Returns a string with the current working directory or nil + plus an error string.
    + +
    iter, dir_obj = lfs.dir (path)
    +
    + Lua iterator over the entries of a given directory. + Each time the iterator is called with dir_obj it returns a directory entry's name as a string, or + nil if there are no more entries. You can also iterate by calling dir_obj:next(), and + explicitly close the directory before the iteration finished with dir_obj:close(). + Raises an error if path is not a directory. +
    + +
    lfs.lock (filehandle, mode[, start[, length]])
    +
    Locks a file or a part of it. This function works on open files; the + file handle should be specified as the first argument. + The string mode could be either + r (for a read/shared lock) or w (for a + write/exclusive lock). The optional arguments start + and length can be used to specify a starting point and + its length; both should be numbers.
    + Returns true if the operation was successful; in + case of error, it returns nil plus an error string. +
    + +
    lfs.mkdir (dirname)
    +
    Creates a new directory. The argument is the name of the new + directory.
    + Returns true if the operation was successful; + in case of error, it returns nil plus an error string. +
    + +
    lfs.rmdir (dirname)
    +
    Removes an existing directory. The argument is the name of the directory.
    + Returns true if the operation was successful; + in case of error, it returns nil plus an error string.
    + +
    lfs.setmode (file, mode)
    +
    Sets the writing mode for a file. The mode string can be either binary or text. + Returns the previous mode string for the file. This function is only available in Windows, so you may want to make sure that + lfs.setmode exists before using it. +
    + +
    lfs.symlinkattributes (filepath [, aname])
    +
    Identical to lfs.attributes except that + it obtains information about the link itself (not the file it refers to). + This function is not available in Windows so you may want to make sure that + lfs.symlinkattributes exists before using it. +
    + +
    lfs.touch (filepath [, atime [, mtime]])
    +
    Set access and modification times of a file. This function is + a bind to utime function. The first argument is the + filename, the second argument (atime) is the access time, + and the third argument (mtime) is the modification time. + Both times are provided in seconds (which should be generated with + Lua standard function os.time). + If the modification time is omitted, the access time provided is used; + if both times are omitted, the current time is used.
    + Returns true if the operation was successful; + in case of error, it returns nil plus an error string. +
    + +
    lfs.unlock (filehandle[, start[, length]])
    +
    Unlocks a file or a part of it. This function works on + open files; the file handle should be specified as the first + argument. The optional arguments start and + length can be used to specify a starting point and its + length; both should be numbers.
    + Returns true if the operation was successful; + in case of error, it returns nil plus an error string. +
    +
    + +
    + +
    + +
    +

    Valid XHTML 1.0!

    +

    $Id: manual.html,v 1.45 2009/06/03 20:53:55 mascarenhas Exp $

    +
    + +
    + + +