LibPkg
|
Base class to manipulate the RISC OS boot options files in Choices. More...
#include <boot_options_file.h>
Classes | |
class | commit_error |
An exception class for reporting failure to commit a boot options file. More... | |
Public Member Functions | |
boot_options_file (const char *file_name, const char *section_prefix, const char *section_version, const char *section_suffix, const char *command, const char *command2=0) | |
Construct boot_options_file object by setting parameters for the options file it will edit. More... | |
virtual | ~boot_options_file () |
void | rollback () |
Discard any changes and reload the file. More... | |
void | commit () |
Commit any changes to the file. More... | |
bool | contains (const std::string &app) const |
Check if application is contained in the look ups. More... | |
bool | add (const std::string &app) |
Add application to up section. More... | |
bool | remove (const std::string &app) |
Remove application from section. More... | |
bool | replace (const std::string &was_app, const std::string &app) |
Replace an application. More... | |
const std::string & | read_pathname () const |
The path name to the location of the PreDesk file that contains the look at declarations for reading. More... | |
const std::string & | write_pathname () const |
The path name to the location of the PreDesk file that any changes to the look at declarations will be written to. More... | |
void | use_test_pathname (const std::string &pathname) |
Change the path name for read or write. More... | |
bool | has_section () const |
See if file has the section defined. More... | |
bool | modified () const |
bool | contains_raw (const std::string &app) const |
Check if exact name is contained in the look ups. More... | |
void | dump_apps () const |
Dump apps array to cout - debugging helper. More... | |
Protected Member Functions | |
virtual char * | find_insert_section ()=0 |
char * | find_section (const char *name, const char *suffix) |
Find section in the file. More... | |
void | parse_section () |
Parse section we are interested into C++ structures. More... | |
bool | parse_word (char *&pos, std::string &word) const |
Parse a single word from the given location. More... | |
char * | find_section_end (char *section) const |
Find the end of the section. More... | |
char * | next_line (char *line) const |
Return adress of start of next line. More... | |
std::string | name_in_section (const std::string &app) const |
Generate the name used in the file. More... | |
Base class to manipulate the RISC OS boot options files in Choices.
pkg::boot_options_file::boot_options_file | ( | const char * | file_name, |
const char * | section_prefix, | ||
const char * | section_version, | ||
const char * | section_suffix, | ||
const char * | command, | ||
const char * | command2 = 0 |
||
) |
Construct boot_options_file object by setting parameters for the options file it will edit.
file_name | Choices file name to be updated |
section_prefix | prefix for section title |
section_version | section version |
section_suffix | suffix for section title |
command | command to write to section |
command2 | optional second command for section |
References rollback().
|
virtual |
void pkg::boot_options_file::rollback | ( | ) |
Discard any changes and reload the file.
std::runtime_error | if it fails to open the file |
References parse_section().
Referenced by boot_options_file().
void pkg::boot_options_file::commit | ( | ) |
Commit any changes to the file.
Does nothing if no modifications have been made
std::ios_base::failure | if commit fails to write the file |
References pkg::create_directory(), dst_pathname, find_insert_section(), find_section_end(), pkg::force_delete(), pkg::force_move(), next_line(), pkg::object_type(), and pkg::write_filetype().
Referenced by pkg::commit::poll().
bool pkg::boot_options_file::contains | ( | const std::string & | app | ) | const |
Check if application is contained in the look ups.
app | application to check |
References name_in_section().
bool pkg::boot_options_file::add | ( | const std::string & | app | ) |
Add application to up section.
app | name of application to add |
References name_in_section().
Referenced by pkg::commit::poll().
bool pkg::boot_options_file::remove | ( | const std::string & | app | ) |
Remove application from section.
app | name of application to remove |
References name_in_section().
Referenced by pkg::commit::poll().
bool pkg::boot_options_file::replace | ( | const std::string & | was_app, |
const std::string & | app | ||
) |
Replace an application.
was_app | application to replace |
app | application to replace it with |
References name_in_section().
|
inline |
The path name to the location of the PreDesk file that contains the look at declarations for reading.
|
inline |
The path name to the location of the PreDesk file that any changes to the look at declarations will be written to.
References has_section(), and use_test_pathname().
void pkg::boot_options_file::use_test_pathname | ( | const std::string & | pathname | ) |
Change the path name for read or write.
This method is for unit testing and would not normally be used. call rollback() to read the test file after this method.
Referenced by write_pathname().
bool pkg::boot_options_file::has_section | ( | ) | const |
See if file has the section defined.
Referenced by write_pathname().
|
inline |
bool pkg::boot_options_file::contains_raw | ( | const std::string & | app | ) | const |
Check if exact name is contained in the look ups.
Used for Unit testing to check that entries of format "Boot:^..."
app | application to check (is not standardized) |
Referenced by modified().
void pkg::boot_options_file::dump_apps | ( | ) | const |
Dump apps array to cout - debugging helper.
Referenced by modified().
|
protectedpure virtual |
Implemented in pkg::add_to_apps_options, pkg::run_options, and pkg::look_at_options.
Referenced by commit(), and modified().
|
protected |
Find section in the file.
Section format is |Start <name> <version> <suffix> where <version> is of form n.nn
name | name of section |
suffix | suffix name of section |
Referenced by pkg::look_at_options::find_insert_section(), pkg::run_options::find_insert_section(), pkg::add_to_apps_options::find_insert_section(), modified(), and parse_section().
|
protected |
Parse section we are interested into C++ structures.
References find_section(), and parse_word().
Referenced by modified(), and rollback().
|
protected |
Parse a single word from the given location.
Skips spaces, then a word is defined until the next space, char 0 or line feed.
pos | location to start parsing - updated to position of character after word |
word | parsed out (empty if at end of line) |
Referenced by modified(), and parse_section().
|
protected |
Find the end of the section.
section | location in section to find |
Referenced by commit(), and modified().
|
protected |
Return adress of start of next line.
line | line to find next line for |
Referenced by commit(), and modified().
|
protected |
Generate the name used in the file.
This usually involves replacing the start with Boot:^ if it's on the boot drive
app | name of application |
References pkg::canonicalise().
Referenced by add(), contains(), modified(), remove(), and replace().
Reference Manual | LibPkg | Version 0.6.1 (28 Jan 2015) |