E-MailRelay
|
A class for reading and writing windows-style startup batch files containing a single command-line, optionally using "start". More...
#include <gbatchfile.h>
Public Member Functions | |
BatchFile (const Path &) | |
Constructor that reads from a file. More... | |
BatchFile (const Path &, std::nothrow_t) | |
Constructor that reads from a file that might be missing or empty. More... | |
std::string | line () const |
Returns the main command-line from within the batchfile, with normalised spaces, without any "start" prefix, and including quotes. More... | |
bool | empty () const |
Returns true if line() is empty. More... | |
std::string | name () const |
Returns the "start" window name, if any. More... | |
const StringArray & | args () const |
Returns the startup command-line broken up into de-quoted pieces. More... | |
std::size_t | lineArgsPos () const |
Returns the position in line() where the arguments start. More... | |
Static Public Member Functions | |
static void | write (const Path &new_batch_file, const StringArray &args, const std::string &start_window_name={}, bool do_backup=false) |
Writes a startup batch file, including a "start" prefix. More... | |
A class for reading and writing windows-style startup batch files containing a single command-line, optionally using "start".
Eg:
Batch files always use the OEM code page on Windows but at this interface it's all UTF-8.
Definition at line 52 of file gbatchfile.h.
|
explicit |
Constructor that reads from a file.
Definition at line 32 of file gbatchfile.cpp.
G::BatchFile::BatchFile | ( | const Path & | path, |
std::nothrow_t | |||
) |
Constructor that reads from a file that might be missing or empty.
The line() will be empty if construction fails.
Definition at line 37 of file gbatchfile.cpp.
const G::StringArray & G::BatchFile::args | ( | ) | const |
Returns the startup command-line broken up into de-quoted pieces.
The first item in the list will be the executable.
Definition at line 176 of file gbatchfile.cpp.
bool G::BatchFile::empty | ( | ) | const |
Returns true if line() is empty.
Definition at line 72 of file gbatchfile.cpp.
std::string G::BatchFile::line | ( | ) | const |
Returns the main command-line from within the batchfile, with normalised spaces, without any "start" prefix, and including quotes.
Definition at line 166 of file gbatchfile.cpp.
std::size_t G::BatchFile::lineArgsPos | ( | ) | const |
Returns the position in line() where the arguments start.
Definition at line 181 of file gbatchfile.cpp.
std::string G::BatchFile::name | ( | ) | const |
Returns the "start" window name, if any.
Definition at line 171 of file gbatchfile.cpp.
|
static |
Writes a startup batch file, including a "start" prefix.
If the "start" window name is not supplied then it is derived from the command-line. The 'args' must not contain double-quote characters. The first 'args' item is the target executable.
Definition at line 204 of file gbatchfile.cpp.