LC.fs.*

Das Modul LC.fs stellt Funktionen zur Verwaltung von Dateien und Verzeichnissen bereit.

LC.fs.basename(filename)
Parameter
  • filename (String) – file name to extract basename from

Rückgabe

base name (file name without path)

LC.fs.copy(sourcefile, destfile)
Parameter
  • sourcefile (String) – Quell-Dateiname

  • destfile (String) – Ziel-Dateiname

Rückgabe

true oder false + Fehlermeldung

Kopiert die Datei sourcefile nach destfile. Die Dateieigenschaften (Besitzer, Berechtigungen und Änderungs-/Zugriffsdatum) bleiben dabei erhalten.

LC.fs.dirname(filename)
Parameter
  • filename (String) – file name to extract directory name from

Rückgabe

directory name (without file name)

LC.fs.filecount(path)
Parameter
  • path (String) – directory name to count files in

Rückgabe

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)
Parameter
  • pattern (String) – zu suchendes Dateisystem-Muster

Rückgabe

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)
Parameter
  • name (String) – zu prüfender Dateiname

Rückgabe

true oder false

Gibt true zurück wenn name ein Verzeichnis ist.

LC.fs.is_file(name)
Parameter
  • name (String) – zu prüfender Dateiname

Rückgabe

true oder false

Gibt true zurück wenn name eine reguläre Datei ist.

Parameter
  • name (String) – zu prüfender Dateiname

Rückgabe

true oder false

Gibt true zurück wenn name ein symbolischer Link ist.

LC.fs.mkdir(name)
Parameter
  • name (String) – zu erstellender Verzeichnisname

Rückgabe

true oder false + Fehlermeldung

Erstellt ein neues Verzeichnis.

LC.fs.mkdir_rec(name[, mode, user, group])
Parameter
  • 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)

Rückgabe

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)
Parameter
  • filename (String) – name of file to parse

Rückgabe

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)
Parameter
  • oldname (String) – umzubenennende Datei oder Verzeichnis

  • newname (String) – neuer Name

Rückgabe

true oder false + Fehlermeldung

Rename a file or a directory from oldname to newname.

LC.fs.setperm(name, mode, user, group)
Parameter
  • 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)

Rückgabe

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)
Parameter
  • user (String) – user to set quota for

  • path (String) – file system (path) to set quota

  • limit (Number) – quota limit (kB)

Rückgabe

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)
Parameter
  • group (String) – group to set quota for

  • path (String) – file system (path) to set quota

  • limit (Number) – quota limit (kB)

Rückgabe

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)
Parameter
  • user (String) – user to get quota for

  • path (String) – Dateisystem (Pfad)

Rückgabe

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)
Parameter
  • group (String) – group to get quota for

  • path (String) – Dateisystem (Pfad)

Rückgabe

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().


Zuletzt aktualisiert am 15.09.2020.
weiter: LC.log.*
zurück: LC.expect.*