LC.fs.*¶
The module LC.fs
provides methods for management of files and directories.
-
LC.fs.
basename
(filename)¶ -
- Arguments
-
-
filename (String) – file name to extract basename from
-
- Returns
-
base name (file name without path)
-
LC.fs.
copy
(sourcefile, destfile)¶ -
- Arguments
-
-
sourcefile (String) – source file name
-
destfile (String) – destination file name
-
- Returns
-
true
orfalse
+ error message
Copy the file
sourcefile
todestfile
, keeping all file attributes (owner, permissions, modification time).
-
LC.fs.
dirname
(filename)¶ -
- Arguments
-
-
filename (String) – file name to extract directory name from
-
- Returns
-
directory name (without file name)
-
LC.fs.
filecount
(path)¶ -
- Arguments
-
-
path (String) – directory name to count files in
-
- Returns
-
number of files in that directory, or
false
+ error message
Return the number of files and directories in
path
(excluding.
and..
). Non-recursive.
-
LC.fs.
glob
(pattern)¶ -
- Arguments
-
-
pattern (String) – filename pattern to match
-
- Returns
-
array of matched file names
Build a list of file names which match
pattern
(e.g./etc/liveconfig/lua.d/*.lua
). If no matching files are found, an empty list is returned. The results are sorted alphabetically.
-
LC.fs.
is_dir
(name)¶ -
- Arguments
-
-
name (String) – filename to check
-
- Returns
-
true
orfalse
Return
true
ifname
is a directory.
-
LC.fs.
is_file
(name)¶ -
- Arguments
-
-
name (String) – filename to check
-
- Returns
-
true
orfalse
Return
true
ifname
is a regular file.
-
LC.fs.
is_symlink
(name)¶ -
- Arguments
-
-
name (String) – filename to check
-
- Returns
-
true
orfalse
Return
true
ifname
is a symbolic link.
-
LC.fs.
mkdir
(name)¶ -
- Arguments
-
-
name (String) – directory name to create
-
- Returns
-
true
orfalse
+ error message
Create a new directory.
-
LC.fs.
mkdir_rec
(name[, mode, user, group])¶ -
- Arguments
-
-
name (String) – directory name to create
-
mode (String) – permission mode (octal value as string, e.g.
0755
) -
user (String) – directory owner (user) (default:
root
) -
group (String) – directory owner (group) (default:
root
)
-
- Returns
-
true
orfalse
+ error message
Create a new directory. If one or more of the parent directories don’t exist, they’re also created.
The parameters
mode
,user
andgroup
are optional. If a directory is created recursively, all parent directories are also created withmode
,user
andgroup
.
-
LC.fs.
parse_ini
(filename)¶ -
- Arguments
-
-
filename (String) – name of file to parse
-
- Returns
-
table with key-value-pairs of .ini content
This function parses the given file (.ini format) and returns the contents as key-value-pairs. If an error occurs, it returns nil and an error string.
-
LC.fs.
rename
(oldname, newname)¶ -
- Arguments
-
-
oldname (String) – file or directory to rename
-
newname (String) – new name
-
- Returns
-
true
orfalse
+ error message
Rename a file or a directory from
oldname
tonewname
.
-
LC.fs.
setperm
(name, mode, user, group)¶ -
- Arguments
-
-
name (String) – file or directory name
-
mode (String) – new file mode (octal value, must be submitted as string!)
-
user (String) – file owner (user)
-
group (String) – file owner (group)
-
- Returns
-
true
orfalse
+ error message
Change the permissions for the file or directory
name
. The new permissions must be submitted as string with an octal value (e.g."0755"
), anduser
/group
is the new file owner name.
-
LC.fs.
setUserQuota
(user, path, limit)¶ -
- Arguments
-
-
user (String) – user to set quota for
-
path (String) – file system (path) to set quota
-
limit (Number) – quota limit (kB)
-
- Returns
-
true
orfalse
+ error message
Set the diskspace quota for user
user
on the device mounted atpath
tolimit
kilobyte.Example: set limit for user
v12007
on/var/www/v12007
to 200 MB (=204800 kB):LC.fs.setUserQuota("v12007", "/var/www/v12007", 204800)
-
LC.fs.
setGroupQuota
(group, path, limit)¶ -
- Arguments
-
-
group (String) – group to set quota for
-
path (String) – file system (path) to set quota
-
limit (Number) – quota limit (kB)
-
- Returns
-
true
orfalse
+ error message
Set the diskspace quota for group
group
on the device mounted atpath
tolimit
kilobyte.
-
LC.fs.
getUserQuota
(user, path)¶ -
- Arguments
-
-
user (String) – user to get quota for
-
path (String) – file system (path)
-
- Returns
-
table or
nil
+ error message (see description)
Get the diskspace quota for user
user
on the device mounted atpath
. The results are returned as table with the following fields:-
kb_soft
soft limit in kilobytes (1024 bytes) -
kb_hard
hard limit -
kb_used
disk space actually used -
n_soft
soft limit of inodes (number of files & directories) -
n_hard
hard limit of inodes -
n_used
number of inodes in use
If an error occured,
nil
and an error message (String) is returned.
-
LC.fs.
getGroupQuota
(group, path)¶ -
- Arguments
-
-
group (String) – group to get quota for
-
path (String) – file system (path)
-
- Returns
-
table or
nil
+ error message (see description)
Get the diskspace quota for group
group
on the device mounted atpath
. The result table is analogous toLC.fs.getUserQuota()
.