1.3. Filesystem API

The Filesystem API provides file system utilities.

Functions

function isdir(string path)

Check if the specified path is a directory.

Return
true if it’s a direcory, false otherwise.
Parameters
  • path: to check.

function mkdir(string path)

Create the specified directory structure.

Return
true on success, false otherwise.
Parameters
  • path: the directory tree to create.

function notEmptyFile(string filename)

Check if the specified file is not empty.

Return
true if file is not empty, false otherwise.
Parameters
  • filename: the file to check.

function exists(string path)

Check if the specified file or directory exists.

Return
true if the path exists, false otherwise.
Parameters
  • path: the path to check.

function fileLastChange(string filename)

Get the last time the specified file has changed.

Return
last modification time on success, -1 otherwise.
Parameters
  • filename: the file to query.

function readdir(string path)

List directory files and dirs contents.

Return
table (entry_name -> entry_name) on success, nil otherwise.
Parameters
  • path: the directory to traverse.

function rmdir(string path)

Recursively remove a file or directory.

Parameters
  • path: the path to remove.

function dumpBinaryFile(string path)

Dump a file contents to the webserver.

Parameters
  • path: the file path.

function setDefaultFilePermissions(string file_path)

Set the default ntopng file permissions on the given path.

Note
this function can fix some permission mismatches on Ubuntu 18.
Parameters
  • file_path: the path to the file

function deleteOldRRDs(string ifpath, int deadline)

Delete RRDs older than the specified deadline.

Parameters
  • ifpath: starting path for the delete operation
  • deadline: maximum modification date for the files