Ghulbus Inc. - Projects

Lua Filesystem Library

A library for performing filesystem operations with Lua.

One of the few things that you can not do with Lua is browse through your file system. There is simply no function to list the files in a directory. However, this is not only a problem of Lua but of ANSI C as well. While under C++ you have at least the possibility of using the Boost filesystem library, you have to rely entirely on proprietary API calls in C.

If you want to use Lua as replacement for a classic standalone scripting language (like Perl or Python), you usually need at least rudimentary access to the filesystem. That is where this library comes into play. It provides a couple of functions for performing simple filesystem operations, like listing the contents of a directory as well as deleting or moving files.

Note that there already exists an 'official' filesystem library for Lua at the Kepler project. My library was written for educational purposes only and is by no means meant to compete with the official library!

This library was tested under GNU Linux and Windows.

Example

This example script generates and prints a tree of all files, directories and subdirectories starting at a given path. Don't try to list your root directory though, unless you have some time to spare. Get the script

Download

Download Download Source (ANSI-C), 3 KB

Known Issues

None :)

Version History

* V-1.0 (Dec. 2007)
 - Initial release.
 - Functions: filesys.ls, filesys.pwd, filesys.mkdir,
     filesys.rmdir, filesys.rmfile, filesys.rm, 
     filesys.rename, filesys.mv

Valid XHTML 1.0 Strict