Jetson Inference
DNN Vision Library

network Networking TCP/UDP sockets and IP address manipulation. More...

Functions

std::string absolutePath (const std::string &relative_path)
 Given a relative path, resolve the absolute path based on the location of the process that calls the function. More...
 
std::string locateFile (const std::string &path)
 Return a list of all the files in the specified directory. More...
 
std::string locateFile (const std::string &path, std::vector< std::string > &locations)
 Locate a file from a set of locations provided by the user, in addition to common system locations such as "/opt" and "/usr/local". More...
 
bool fileExists (const char *path, bool regularFilesOnly=false)
 Verify path and return true if the file exists. More...
 
size_t fileSize (const char *path)
 Return the size (in bytes) of the specified file. More...
 
std::string filePath (const std::string &filename)
 Extract the path out of the supplied string, removing the filename and extension For example, filePath("~/user/somefile.xml") would return ~/user More...
 
std::string fileExtension (const std::string &path)
 Extract the file extension from the path. More...
 
std::string fileRemoveExtension (const std::string &filename)
 Return the input string with the file extension removed For example, strRemoveExtension("~/user/somefile.xml") would return ~/user/somefile. More...
 
std::string fileChangeExtension (const std::string &filename, const std::string &newExtension)
 Return the input string with a changed file extension For example, strChangeExtension("~/user/somefile.xml", "zip") would return ~/user/somefile.zip. More...
 
std::string processPath ()
 Return the absolute path that of the calling process executable, include the process executable's filename. More...
 
std::string processDirectory ()
 Return the directory that the calling process resides in. More...
 
std::string workingDirectory ()
 Return the current working directory of the calling process. More...
 

Detailed Description

network Networking TCP/UDP sockets and IP address manipulation.

Functions for listing files in directories and manipulating file paths.

Function Documentation

◆ absolutePath()

std::string absolutePath ( const std::string &  relative_path)

Given a relative path, resolve the absolute path based on the location of the process that calls the function.

For example, if the application is located at "/home/user/my_process" and absolutePath("resources/example") is called, then this function would return the path "/home/user/resources/example".

◆ fileChangeExtension()

std::string fileChangeExtension ( const std::string &  filename,
const std::string &  newExtension 
)

Return the input string with a changed file extension For example, strChangeExtension("~/user/somefile.xml", "zip") would return ~/user/somefile.zip.

◆ fileExists()

bool fileExists ( const char *  path,
bool  regularFilesOnly = false 
)

Verify path and return true if the file exists.

Parameters
regularFilesOnlyIf false (which is the default), then sysFileExists() includes filesystem entries like directories, device files, and sockets when verifying the path.

If regularFilesOnly parameter is true, then sysFileExists() will verify the path is to a readable, "regular" file. Other file types (for example directories) will result in sysFileExists() returning false.

◆ fileExtension()

std::string fileExtension ( const std::string &  path)

Extract the file extension from the path.

This function will return all contents of the path to the right of the right-most `'.'` The extension will be returned in all lowercase characters.

◆ filePath()

std::string filePath ( const std::string &  filename)

Extract the path out of the supplied string, removing the filename and extension For example, filePath("~/user/somefile.xml") would return ~/user

◆ fileRemoveExtension()

std::string fileRemoveExtension ( const std::string &  filename)

Return the input string with the file extension removed For example, strRemoveExtension("~/user/somefile.xml") would return ~/user/somefile.

◆ fileSize()

size_t fileSize ( const char *  path)

Return the size (in bytes) of the specified file.

Parameters
paththe path of the file
Returns
if successful, the size of the file in bytes otherwise, 0 will be returned.

◆ locateFile() [1/2]

std::string locateFile ( const std::string &  path)

Return a list of all the files in the specified directory.

Parameters
paththe path of the directory
listthe output list of all files in the directory
includePathif true, the list of filenames will be prefixed with the path if false (default), the list of filenames will contain filenames/extensions only Locate a file from common system locations. First, this function will check if the file exists at the path provided, and if not it will check for the existance of the file in common system locations such as "/opt", "/usr/local", and "/usr/local/bin".
Returns
the confirmed path of the located file, or empty string if the file could not be found

◆ locateFile() [2/2]

std::string locateFile ( const std::string &  path,
std::vector< std::string > &  locations 
)

Locate a file from a set of locations provided by the user, in addition to common system locations such as "/opt" and "/usr/local".

Returns
the confirmed path of the located file, or empty string if the file could not be found

◆ processDirectory()

std::string processDirectory ( )

Return the directory that the calling process resides in.

For example, if the process executable is located at /usr/bin/exe, then processDirectory() would return the path /usr/bin.

Note
to retrieve the full path of the calling process, including the process executable's filename,
See also
processPath()

◆ processPath()

std::string processPath ( )

Return the absolute path that of the calling process executable, include the process executable's filename.

◆ workingDirectory()

std::string workingDirectory ( )

Return the current working directory of the calling process.