TSDuck Version 3.15-964 (TSDuck - The MPEG Transport Stream Toolkit)
tsSysUtils.h File Reference

Various system utilities. More...

Classes

struct  ts::ProcessMetrics
 This structure contains metrics about a process. More...
 

Namespaces

 ts
 TSDuck namespace, containing all TSDuck classes and functions.
 

Macros

#define TS_COMMAND_PATH   platform-specific ("PATH", "Path")
 Environment variable containing the command search path.
 
#define TS_EXECUTABLE_SUFFIX   platform-specific (".exe", "")
 Executable file suffix.
 
#define TS_PLUGINS_PATH   u"TSPLUGINS_PATH"
 Name of the environment variable which contains a list of paths for plugins.
 
#define TS_SHARED_LIB_SUFFIX   platform-specific (".dll", ".so")
 File name extension of shared library file names (".so" on UNIX, ".dll" on Windows).
 

Typedefs

typedef std::map< UString, UString > ts::Environment
 Define a container type holding all environment variables. More...
 
typedef platform_specific ts::ProcessId
 Integer type for process identifier.
 

Functions

UString ts::AddPathSuffix (const UString &path, const UString &suffix)
 Conditionally add a suffix to a file path. More...
 
UString ts::BaseName (const UString &path, const UString &suffix=UString())
 Return the base file name of a file path ("dir/foo.bar" => "foo.bar"). More...
 
ErrorCode ts::CreateDirectory (const UString &path)
 Create a directory. More...
 
ProcessId ts::CurrentProcessId ()
 Get the current process id. More...
 
bool ts::DeleteEnvironment (const UString &name)
 Delete an environment variable. More...
 
ErrorCode ts::DeleteFile (const UString &path)
 Delete a file or directory. More...
 
UString ts::DirectoryName (const UString &path)
 Return the directory name of a file path ("dir/foo.bar" => "dir"). More...
 
bool ts::EnvironmentExists (const UString &varname)
 Check if an environment variable exists. More...
 
UString ts::ErrorCodeMessage (ErrorCode code=LastErrorCode())
 Format an error code into a string. More...
 
UString ts::ExecutableFile ()
 Get the name of the current application executable file. More...
 
UString ts::ExpandEnvironment (const UString &path)
 Expand environment variables inside a file path (or any string). More...
 
template<class CONTAINER >
bool ts::ExpandWildcard (CONTAINER &container, const UString &pattern)
 Get all files matching a specified wildcard pattern. More...
 
template<class CONTAINER >
bool ts::ExpandWildcardAndAppend (CONTAINER &container, const UString &pattern)
 Get all files matching a specified wildcard pattern and append them into a container. More...
 
bool ts::FileExists (const UString &path)
 Check if a file or directory exists. More...
 
UString ts::GetEnvironment (const UString &varname, const UString &defvalue=UString())
 Get the value of an environment variable. More...
 
void ts::GetEnvironment (Environment &env)
 Get the content of the entire environment (all environment variables). More...
 
template<class CONTAINER >
void ts::GetEnvironmentPath (CONTAINER &container, const UString &name, const UString &def=UString())
 Get the value of an environment variable containing a search path. More...
 
Time ts::GetFileModificationTimeLocal (const UString &path)
 Get the local time of the last modification of a file. More...
 
Time ts::GetFileModificationTimeUTC (const UString &path)
 Get the UTC time of the last modification of a file. More...
 
int64_t ts::GetFileSize (const UString &path)
 Get the size in bytes of a file. More...
 
void ts::GetProcessMetrics (ProcessMetrics &metrics)
 Get metrics for the current process. More...
 
void ts::IgnorePipeSignal ()
 Ensure that writing to a broken pipe does not kill the current process. More...
 
bool ts::IsDirectory (const UString &path)
 Check if a path exists and is a directory. More...
 
bool ts::IsPrivilegedUser ()
 Check if the current user is privileged (root on UNIX, an administrator on Windows). More...
 
bool ts::LoadEnvironment (Environment &env, const UString &fileName)
 Load a text file containing environment variables. More...
 
UString ts::PathPrefix (const UString &path)
 Return the prefix of a file path ("dir/foo.bar" => "dir/foo"). More...
 
UString ts::PathSuffix (const UString &path)
 Return the suffix of a file path ("dir/foo.bar" => ".bar"). More...
 
ErrorCode ts::RenameFile (const UString &old_path, const UString &new_path)
 Rename / move a file or directory. More...
 
UString ts::SearchConfigurationFile (const UString &fileName)
 Search a configuration file. More...
 
bool ts::SetBinaryModeStdin (Report &report=(*ts::CerrReport::Instance()))
 Put the standard input stream in binary mode. More...
 
bool ts::SetBinaryModeStdout (Report &report=(*ts::CerrReport::Instance()))
 Put the standard output stream in binary mode. More...
 
bool ts::SetEnvironment (const UString &name, const UString &value)
 Set the value of an environment variable. More...
 
void ts::SleepThread (MilliSecond delay)
 Suspend the current thread for the specified period. More...
 
bool ts::StdErrIsTerminal ()
 Check if the standard error is a terminal. More...
 
bool ts::StdInIsTerminal ()
 Check if the standard input is a terminal. More...
 
bool ts::StdOutIsTerminal ()
 Check if the standard output is a terminal. More...
 
UString ts::TempDirectory ()
 Return the name of a directory for temporary files. More...
 
UString ts::TempFile (const UString &suffix=u".tmp")
 Return the name of a unique temporary file. More...
 
ErrorCode ts::TruncateFile (const UString &path, uint64_t size)
 Truncate a file to the specified size. More...
 
UString ts::UserHomeDirectory ()
 Get the current user's home directory. More...
 
UString ts::VernacularFilePath (const UString &path)
 Return a "vernacular" version of a file path. More...
 

Variables

const CaseSensitivity ts::FileSystemCaseSensitivity = platform-specific
 Case-sensitivity of the names in the file system.
 
const UChar ts::PathSeparator = platform-specific ('/', '\\')
 Directory separator character in file paths.
 
const char ts::SearchPathSeparator = platform-specific (':', ';')
 Separator character in search paths.
 

Detailed Description

Various system utilities.