libzypp 17.37.10

zypp::base::sysconfig Namespace Reference

## Functions
std::map< std::string, std::string > | read (const Pathname &_path) ZYPP_API
| Read sysconfig file path_r and return (key,valye) pairs.
bool | write (const Pathname &path_r, const std::string &key_r, const std::string &val_r, const std::string &newcomment_r=std::string()) ZYPP_API
| Add or change a value in sysconfig file path_r.
bool | writeStringVal (const Pathname &path_r, const std::string &key_r, const std::string &val_r, const std::string &newcomment_r=std::string()) ZYPP_API
| Convenience to add or change a string-value in sysconfig file path_r.

## Function Documentation

## ◆ read()

std::map< std::string, std::string > zypp::base::sysconfig::read | ( | const Pathname & | _path | ) |

Read sysconfig file path_r and return (key,valye) pairs.

Definition at line 34 of file sysconfig.cc.

## ◆ write()

bool zypp::base::sysconfig::write | ( | const Pathname & | path_r,
|  | const std::string & | key_r,
|  | const std::string & | val_r,
|  | const std::string & | newcomment_r = std::string() )

Add or change a value in sysconfig file path_r.

If key_r already exists, only the val_r is changed accordingly.

In case key_r is not yet present in the file, a new entry may be created at the end of the file, using the lines in newcomment_r as comment block. If newcomment_r is not provided or empty, a new value is not created and `false` is returned.

Returns
  `TRUE` if an entry was changed or created.

Exceptions

  Exception | if path_r can not be read or written.

Note
  val_r is written as it is. The caller is responsible for escaping and enclosing in '"', in case this is needed (

See also
  writeStringVal and str::escape).

Note
  Lines in newcomment_r which do not already start with a '#', are prefixes with "# ".

## Type: string
## Default: ""
#
# A multiline description of
# the options purpose.
#
KEY="value"

Definition at line 80 of file sysconfig.cc.

## ◆ writeStringVal()

bool zypp::base::sysconfig::writeStringVal | ( | const Pathname & | path_r,
|  | const std::string & | key_r,
|  | const std::string & | val_r,
|  | const std::string & | newcomment_r = std::string() )

Convenience to add or change a string-value in sysconfig file path_r.

val_r is expected to be a plain string value, so it is propery escaped and enclosed in double quotes before it is written to the sysconfig file path_r.

See also
  write

Definition at line 148 of file sysconfig.cc.