From 688efd472ce1a1ea612a3d1720a19a2f65b383a5 Mon Sep 17 00:00:00 2001
From: tuler
-
-
-
-
-LuaFileSystem is a Lua library
-developed to complement the set of functions related to file systems offered
-by the standard Lua distribution.
-
-LuaFileSystem is free software and uses the same
-license
-as Lua 5.0.
-
-LuaFileSystem offers the following functions:
-
-
-
-
-
-
-
-
LuaFileSystem Reference Manual
- File system library for the
-Lua
-programming language
-
-
-
-Introduction
-
-Reference
-
-
-
-
-
-
-
-
- Obtains the file attributes.
- The attributes are:
-
- dev, device inode resides on;
- Returns a table with file attributes described above.
-
-
-
- ino, inode's number;
- mode, inode protection mode (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;
- gid, group-id of owner;
- rdev, device type, for special file inode;
- 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;
- blksize, optimal file system I/O blocksize;
-
- Changes the current working directory to the given path.
- Returns true in case of success or nil plus an error
- string.
-
-
-
- Returns a string with the current working directory or
- nil
plus an error string.
-
-
-
- Lua iterator over the entries of a given directory.
- Raises an error if path is not a directory.
-
-
-
- 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 a boolean indicating if the operation was successful;
- in case of error, it returns false
plus an error string.
-
-
-
- Creates a new directory.
- The argument is the name of the new directory.
- Returns a boolean indicating whether the operation succeeds or not
- (in this case, an error string is returned too).
-
-
-
- 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 a boolean indicating if the operation was successful;
- in case of error, it returns false
plus a string describing the
- error.
-
-Example
-
-
-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 (".")
-
-
-
-
-Contents
-
-
-
-
- -
+![]() |
LuaFileSystem Reference Manual + |
File system library for the +Lua +programming language + |
+ +
+ +
+LuaFileSystem is a Lua library +developed to complement the set of functions related to file systems offered +by the standard Lua distribution. +
+LuaFileSystem is free software and uses the same +license +as Lua 5.0. +
+ + + ++LuaFileSystem offers the following functions: +
nil
plus an error 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.false
plus an error string.
+
+
+ start
and length
can be
+ used to specify a starting point and its length;
+ both should be numbers.false
plus a string describing the
+ error.
+
++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 (".") ++ + + +
+
+
+ +