LuaFileSystem
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. This version 1.5.0 was compiled from the source to work with AutoPlay Media Studio 8.x and Setup Factory 9.x.
LuaFileSystem offers the following functions:
lfs.attributes (filepath [, aname]) |
Returns a table with the file attributes corresponding to
This function uses | ||||||||||||||||||||||||||
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) | Creates a lockfile (called lockfile.lfs) in path if it does not
exist and returns the lock.
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 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.
|
Using with AutoPlay Media Studio 8
Add the lfs.dll to your project, placing it into the Scripts folder. It then can be used on any page or dialog when needed.
Using with Setup Factory 9
Add the lfs.dll to the Primer Files of your project, so it will be decompressed into the runtime folder when the setup is executed. Then, where needed, load it.
Sample code for loading and using the module
-- load LuaFileSystem require "lfs"; lfs.chdir(_TempFolder); Dialog.Message("Info", "The current folder is ".. lfs.currentdir(), MB_OK);
Download
To receive a download link for this software, please click the button below. After the payment is confirmed, you will receive a download link per email automatically and may install this software, use it for commercial and personal projects.
In the past, I offered my work for free, in the hope that individuals and companies would contribute with a minimum payment. Unfortunately, that didn't happen, and the result was so meager, that I didn't even pay half the cost of hosting this site, and I had to change the policy.
Support Policy
All software products were tested and found to work, but they are provided without any explicit guarantee that they will work in every possible environment without further customization. If you need support or consulting, please contact me.