Jetson Inference
DNN Vision Library
filesystem.h File Reference
#include <string>
#include <vector>

Go to the source code of this file.

Enumerations

enum  fileTypes {
  FILE_MISSING = 0, FILE_REGULAR = (1 << 0), FILE_DIR = (1 << 1), FILE_LINK = (1 << 2),
  FILE_CHAR = (1 << 3), FILE_BLOCK = (1 << 4), FILE_FIFO = (1 << 5), FILE_SOCKET = (1 << 6)
}
 File types. More...
 

Functions

std::string absolutePath (const std::string &relative_path)
 Given a relative path, resolve the absolute path using the working directory. More...
 
std::string locateFile (const std::string &path)
 Locate a file from common system locations. 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...
 
std::string readFile (const std::string &path)
 Read a text file into a string. More...
 
std::string pathJoin (const std::string &a, const std::string &b)
 Join two paths, and properly include a path separator (/) as needed. More...
 
std::string pathDir (const std::string &path)
 Return the parent directory of the specified path, removing the filename and extension. More...
 
std::string pathFilename (const std::string &path)
 Return the filename from the path, including the file extension. More...
 
std::pair< std::string, std::string > splitPath (const std::string &path)
 Split a path into directory and filename components. More...
 
bool listDir (const std::string &path, std::vector< std::string > &list, uint32_t mask=0)
 Return a sorted list of the files in the specified directory. More...
 
bool fileExists (const std::string &path, uint32_t mask=0)
 Return the directory /** Verify path and return true if the file exists. More...
 
bool fileIsType (const std::string &path, uint32_t mask)
 Return true if the file is one of the types in the fileTypes mask. More...
 
uint32_t fileType (const std::string &path)
 Return the file type, or FILE_MISSING if it doesn't exist. More...
 
size_t fileSize (const std::string &path)
 Return the size (in bytes) of the specified file. More...
 
std::string fileExtension (const std::string &path)
 Extract the file extension from the path. More...
 
bool fileHasExtension (const std::string &path, const std::string &extension)
 Return true if the file has the given extension, otherwise false. More...
 
bool fileHasExtension (const std::string &path, const std::vector< std::string > &extensions)
 Return true if the file has one of the given extensions, otherwise false. More...
 
bool fileHasExtension (const std::string &path, const char **extensions)
 Return true if the file has one of the given extensions, otherwise false. More...
 
std::string fileRemoveExtension (const std::string &filename)
 Return the input string with the file extension removed For example, fileRemoveExtension("~/workspace/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, fileChangeExtension("~/workspace/somefile.xml", "zip") would return ~/user/somefile.zip. More...