Das Modul LC.fs
stellt Funktionen zur Verwaltung von Dateien und Verzeichnissen bereit.
LC.fs.
basename
(filename)¶
filename (String) – file name to extract basename from
base name (file name without path)
LC.fs.
copy
(sourcefile, destfile)¶
sourcefile (String) – Quell-Dateiname
destfile (String) – Ziel-Dateiname
true
oder false
+ Fehlermeldung
Kopiert die Datei sourcefile
nach destfile
. Die Dateieigenschaften (Besitzer, Berechtigungen und Änderungs-/Zugriffsdatum) bleiben dabei erhalten.
LC.fs.
dirname
(filename)¶
filename (String) – file name to extract directory name from
directory name (without file name)
LC.fs.
filecount
(path)¶
path (String) – directory name to count files in
Anzahl der Dateien in dem Verzeichnis, oder false
+ Fehlermeldung
Return the number of files and directories in path
(excluding .
and ..
). Non-recursive.
LC.fs.
glob
(pattern)¶
pattern (String) – zu suchendes Dateisystem-Muster
Array mit passenden Dateinamen
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)¶
name (String) – zu prüfender Dateiname
true
oder false
Gibt true
zurück wenn name
ein Verzeichnis ist.
LC.fs.
is_file
(name)¶
name (String) – zu prüfender Dateiname
true
oder false
Gibt true
zurück wenn name
eine reguläre Datei ist.
LC.fs.
is_symlink
(name)¶
name (String) – zu prüfender Dateiname
true
oder false
Gibt true
zurück wenn name
ein symbolischer Link ist.
LC.fs.
mkdir
(name)¶
name (String) – zu erstellender Verzeichnisname
true
oder false
+ Fehlermeldung
Erstellt ein neues Verzeichnis.
LC.fs.
mkdir_rec
(name[, mode, user, group])¶
name (String) – zu erstellender Verzeichnisname
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
)
true
oder false
+ Fehlermeldung
Create a new directory. If one or more of the parent directories don’t exist, they’re also created.
The parameters mode
, user
and group
are optional. If a directory is created recursively, all parent directories are also created with mode
, user
and group
.
LC.fs.
parse_ini
(filename)¶
filename (String) – name of file to parse
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)¶
oldname (String) – umzubenennende Datei oder Verzeichnis
newname (String) – neuer Name
true
oder false
+ Fehlermeldung
Rename a file or a directory from oldname
to newname
.
LC.fs.
setperm
(name, mode, user, group)¶
name (String) – Datei- oder Verzeichnisname
mode (String) – new file mode (octal value, must be submitted as string!)
user (String) – Dateibesitzer (Benutzer)
group (String) – Dateibesitzer (Gruppe)
true
oder false
+ Fehlermeldung
Change the permissions for the file or directory name
. The new permissions must be submitted as string with an octal value (e.g. "0755"
), and user
/group
is the new file owner name.
LC.fs.
setUserQuota
(user, path, limit)¶
user (String) – user to set quota for
path (String) – file system (path) to set quota
limit (Number) – quota limit (kB)
true
oder false
+ Fehlermeldung
Set the diskspace quota for user user
on the device mounted at path
to limit
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)¶
group (String) – group to set quota for
path (String) – file system (path) to set quota
limit (Number) – quota limit (kB)
true
oder false
+ Fehlermeldung
Set the diskspace quota for group group
on the device mounted at path
to limit
kilobyte.
LC.fs.
getUserQuota
(user, path)¶
user (String) – user to get quota for
path (String) – Dateisystem (Pfad)
table or nil
+ error message (see description)
Get the diskspace quota for user user
on the device mounted at path
. 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)¶
group (String) – group to get quota for
path (String) – Dateisystem (Pfad)
table or nil
+ error message (see description)
Get the diskspace quota for group group
on the device mounted at path
. The result table is analogous to LC.fs.getUserQuota()
.