|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
RAII wrapper for FILE* from popen(). More...
#include <file_handle.h>
Public Member Functions | |
| PipeHandle (const char *command, const char *mode) | |
| Open pipe for command execution. | |
| PipeHandle (const PipeHandle &)=delete | |
| PipeHandle (const std::string &command, const char *mode) | |
| PipeHandle (PipeHandle &&other) noexcept | |
| ~PipeHandle () | |
| Destructor - automatically closes pipe. | |
| int | close () |
| Close the pipe early and return pclose's exit status. | |
| FILE * | get () const |
| Get raw FILE* pointer. | |
| bool | isOpen () const |
| Check if pipe is open. | |
| operator bool () const | |
| Explicit bool conversion for easy checking. | |
| PipeHandle & | operator= (const PipeHandle &)=delete |
| PipeHandle & | operator= (PipeHandle &&other) noexcept |
| FILE * | release () |
| Release ownership of FILE* without closing. | |
RAII wrapper for FILE* from popen().
Automatically closes pipe handle on destruction, preventing resource leaks. Non-copyable but movable.
Definition at line 155 of file file_handle.h.
|
inline |
Open pipe for command execution.
| command | Shell command to execute |
| mode | Pipe mode ("r" for reading output, "w" for writing input) |
Definition at line 163 of file file_handle.h.
Referenced by PipeHandle(), PipeHandle(), operator=(), and operator=().
|
inline |
Definition at line 165 of file file_handle.h.
|
inline |
Destructor - automatically closes pipe.
Definition at line 172 of file file_handle.h.
|
delete |
References PipeHandle().
|
inlinenoexcept |
Definition at line 186 of file file_handle.h.
References PipeHandle().
|
inline |
Close the pipe early and return pclose's exit status.
Equivalent to letting the destructor run, except the caller gets the wait-status word back (the same value pclose() returns: a wait(2)-style status on success, or -1 on error). Use this when you need to distinguish "command succeeded" from "command crashed / exited non-zero" — the destructor swallows that info. Repeated close() calls are no-ops; the destructor won't double-close.
Inspect the return value with the standard W* macros, e.g.: const int s = pipe.close(); if (s == -1 || (WIFEXITED(s) && WEXITSTATUS(s) != 0)) ...
Definition at line 239 of file file_handle.h.
Referenced by PrefixSnapshotService::importSnapshot().
|
inline |
Get raw FILE* pointer.
Definition at line 209 of file file_handle.h.
Referenced by ProcessExecutor::executeWithLines(), ProcessExecutor::executeWithOutput(), SteamLibraryScanner::fetchGameNameFromSteamAPI(), SteamLibraryScanner::fetchSteamMetadata(), GameProcessManager::getGameSessionDuration(), PrefixSnapshotService::importSnapshot(), and SteamLibraryScanner::loadAppNameCache().
|
inline |
Check if pipe is open.
Definition at line 218 of file file_handle.h.
Referenced by operator bool().
|
inlineexplicit |
Explicit bool conversion for easy checking.
Definition at line 251 of file file_handle.h.
References isOpen().
|
delete |
References PipeHandle().
|
inlinenoexcept |
Definition at line 191 of file file_handle.h.
References PipeHandle().
|
inline |
Release ownership of FILE* without closing.
Definition at line 260 of file file_handle.h.
Referenced by ProcessExecutor::executeWithOutput().