kong.tools.io

Checks existence of a file.

Functions

cmd_exists (cmd) Check existence of a command.
file_size (path) Get the filesize.
kill_process_by_pid_file (pid_file, signal) Kill a process by PID.
os_execute (command) Execute an OS command and catch the output.
read_file (path) Read file contents.
write_to_file (path) Write file contents.

Functions


cmd_exists

Check existence of a command.
Parameters:
  • cmd command being searched for
Returns:
  • true of found, false otherwise

file_size

Get the filesize.
Parameters:
  • path path to file to check
Returns:
  • size of file, or nil on failure

kill_process_by_pid_file

Kill a process by PID. Kills the process and waits until it's terminated
Parameters:
  • pid_file the file containing the pid to kill
  • signal the signal to use
Returns:

os_execute

Execute an OS command and catch the output.
Parameters:
  • command OS command to execute
Returns:
  • string containing command output (both stdout and stderr)
  • exitcode

read_file

Read file contents.
Parameters:
  • path filepath to read
Returns:
  • file contents as string, or nil if not successful

write_to_file

Write file contents.
Parameters:
  • path filepath to write to
Returns:
  • true upon success, or false + error message on failure