![]() |
TSDuck v3.40-4163
MPEG Transport Stream Toolkit
|
Portable operating system layer. More...
Modules | |
File system | |
File system and file path features (in addition to std::filesystem). | |
Environment variables | |
System environment variables features. | |
Multi-threading | |
Multi-threading and synchronization features. | |
Unix | |
Unix specific features. | |
Windows | |
Windows specific features. | |
Files | |
file | tsFileUtils.h |
File utilities (file path, file properties, etc). | |
file | tsSysUtils.h |
Various system utilities. | |
Classes | |
class | ts::AbortInterface |
An interface to check for abort. More... | |
class | ts::AbstractReadStreamInterface |
Abstract interface to read raw data from a stream. More... | |
class | ts::AbstractWriteStreamInterface |
Abstract interface to write raw data on a stream. More... | |
class | ts::ApplicationSharedLibrary |
Representation of an application shared library. More... | |
class | ts::ForkPipe |
Fork a process and create an optional pipe to its standard input. More... | |
class | ts::InputRedirector |
A class to redirect an input stream. More... | |
class | ts::InterruptHandler |
An interface to be implemented by a class to handle user Ctrl-C interrupt. More... | |
class | ts::OutputPager |
Send application output to a "pager" application such as "more" or "less". More... | |
class | ts::OutputRedirector |
A class to redirect an output stream. More... | |
class | ts::ResidentBuffer< T > |
Implementation of memory buffer locked in physical memory. More... | |
class | ts::SharedLibrary |
Shared library handling (.so on Linux, .dylib on macOS, .dll on Windows). More... | |
class | ts::SysInfo |
A singleton holding information on the current operating system. More... | |
class | ts::SystemMonitor |
Monitoring thread for system resources used by the application. More... | |
class | ts::Time |
The Time class implements a basic representation of time. More... | |
class | ts::UserInterrupt |
An instance of this class handles the Ctrl+C user interrupt. More... | |
class | ts::Zlib |
Implementation of RFC 1951 data compression, a.k.a. More... | |
Typedefs | |
using | ts::ioctl_request_t = platform-dependent |
Portable type for ioctl() request parameter. | |
Enumerations | |
enum class | ts::SharedLibraryFlags : uint16_t { ts::SharedLibraryFlags::NONE = 0x00 , ts::SharedLibraryFlags::PERMANENT = 0x01 } |
Bit masks options to load shared libraries. More... | |
Functions | |
fs::path | ts::CallerLibraryFile () |
Get the name of the executable or shared library file containing the caller code. | |
fs::path | ts::ExecutableFile () |
Get the name of the current application executable file. | |
cn::milliseconds | ts::GetProcessCpuTime () |
Get the CPU time of the process in milliseconds. | |
size_t | ts::GetProcessVirtualSize () |
Get the virtual memory size of the process in bytes. | |
void | ts::IgnorePipeSignal () |
Ensure that writing to a broken pipe does not kill the current process. | |
bool | ts::IsPrivilegedUser () |
Check if the current user is privileged (root on UNIX, an administrator on Windows). | |
int | ts::LastSysErrorCode () |
Get the error code of the last operating system call. | |
bool | ts::SetBinaryModeStdin (Report &report=(ts::CerrReport::Instance())) |
Put the standard input stream in binary mode. | |
bool | ts::SetBinaryModeStdout (Report &report=(ts::CerrReport::Instance())) |
Put the standard output stream in binary mode. | |
template<class Rep , class Period > | |
void | ts::SetTimersPrecision (cn::duration< Rep, Period > &precision) |
Request a minimum resolution for the system timers. | |
bool | ts::StdErrIsTerminal () |
Check if the standard error is a terminal. | |
bool | ts::StdInIsTerminal () |
Check if the standard input is a terminal. | |
bool | ts::StdOutIsTerminal () |
Check if the standard output is a terminal. | |
std::string | ts::SysErrorCodeMessage (int code=LastSysErrorCode(), const std::error_category &category=std::system_category()) |
Format a system error code into a string. | |
Portable operating system layer.
|
strong |
Bit masks options to load shared libraries.
Enumerator | |
---|---|
NONE | No option. |
PERMANENT | The shared library remains active when the SharedLibrary object is destroyed (unloaded otherwise). |
|
inline |
Get the error code of the last operating system call.
The validity of the returned value may depends on specific conditions.
Portability of error code representation: On UNIX, error codes are just int
. On Windows, error codes are DWORD
, which is compatible with int
. In C++11, std::error_core
uses int
for error codes. Therefore, because of this new C++11 feature, we just use int
.
Windows note: According to Windows documentation, socket functions should call WSAGetLastError() instead of GetLastError() to retrieve the error code. This is an oddity from the old 16-bit Windows API. On Win32, various sources confirm that WSAGetLastError() just call GetLastError(). Thus, in this application, we do not make the difference.
|
inline |
Format a system error code into a string.
[in] | code | An error code from the operating system. Typically a result from errno (Unix) or GetLastError() (Windows). |
[in] | category | Error category, system by default. |
fs::path ts::ExecutableFile | ( | ) |
Get the name of the current application executable file.
fs::path ts::CallerLibraryFile | ( | ) |
Get the name of the executable or shared library file containing the caller code.
bool ts::IsPrivilegedUser | ( | ) |
Check if the current user is privileged (root on UNIX, an administrator on Windows).
cn::milliseconds ts::GetProcessCpuTime | ( | ) |
Get the CPU time of the process in milliseconds.
ts::Exception | on error. |
size_t ts::GetProcessVirtualSize | ( | ) |
Get the virtual memory size of the process in bytes.
ts::Exception | on error. |
void ts::IgnorePipeSignal | ( | ) |
Ensure that writing to a broken pipe does not kill the current process.
On UNIX systems, writing to a broken pipe, i.e. a pipe with no process reading from it, kills the current process. This may not be what you want. This functions prevents this.
UNIX Systems: This function ignores SIGPIPE. Writing to a broken pipe will now return an error instead of killing the process.
Windows systems: This function does nothing (because there is no need to do anything).
void ts::SetTimersPrecision | ( | cn::duration< Rep, Period > & | precision | ) |
Request a minimum resolution for the system timers.
[in,out] | precision | On input, specify the requested minimum resolution in any std::chrono::duration units. On output, return the obtained guaranteed minimum resolution. The guaranteed precision value can be equal to or greater than the requested value. The default system resolution is 20 ms on Win32, which can be too long for applications. |
bool ts::StdInIsTerminal | ( | ) |
Check if the standard input is a terminal.
bool ts::StdOutIsTerminal | ( | ) |
Check if the standard output is a terminal.
bool ts::StdErrIsTerminal | ( | ) |
Check if the standard error is a terminal.
bool ts::SetBinaryModeStdin | ( | Report & | report = (ts::CerrReport::Instance()) | ) |
Put the standard input stream in binary mode.
On UNIX systems, this does not make any difference. On Windows systems, however, in a stream which is not open in binary mode, there is automatic translation between LF and CR-LF. The standard input is open in text mode (non-binary). This function forces it into binary mode.
[in,out] | report | Where to report errors. |
bool ts::SetBinaryModeStdout | ( | Report & | report = (ts::CerrReport::Instance()) | ) |
Put the standard output stream in binary mode.
On UNIX systems, this does not make any difference. On Windows systems, however, in a stream which is not open in binary mode, there is automatic translation between LF and CR-LF. The standard output is open in text mode (non-binary). This function forces it into binary mode.
[in,out] | report | Where to report errors. |