base/utils/paths.zeek

Functions to parse and manipulate UNIX style paths and directories.

Summary

Functions

build_path: function

Constructs a path to a file given a directory and a file name.

build_path_compressed: function

Returns a compressed path to a file given a directory and file name.

extract_path: function

Given an arbitrary string, extracts a single, absolute path (directory with filename).

Detailed Interface

Constants

absolute_path_pat
Type

pattern

Default
/^?((\/|[A-Za-z]:[\\\/]).*)$?/

Functions

build_path
Type

function (dir: string, file_name: string) : string

Constructs a path to a file given a directory and a file name.

Dir

the directory in which the file lives.

File_name

the name of the file.

Returns

the concatenation of the directory path and file name, or just the file name if it’s already an absolute path or dir is empty.

build_path_compressed
Type

function (dir: string, file_name: string) : string

Returns a compressed path to a file given a directory and file name. See build_path and compress_path.

extract_path
Type

function (input: string) : string

Given an arbitrary string, extracts a single, absolute path (directory with filename).

Todo

Make this work on Window’s style directories.

Input

a string that may contain an absolute path.

Returns

the first absolute path found in input string, else an empty string.