prc: Add ConfigVariableFilename.__fspath__()

Fixes #1406
This commit is contained in:
rdb 2022-12-06 12:52:44 +01:00
parent 41f0c9d48d
commit 32f9054067
2 changed files with 13 additions and 0 deletions

View File

@ -218,6 +218,17 @@ set_word(size_t n, const Filename &value) {
set_string_word(n, value);
}
/**
* Allows a ConfigVariableFilename object to be passed to any Python function
* that accepts an os.PathLike object.
*
* @since 1.10.13
*/
INLINE std::wstring ConfigVariableFilename::
__fspath__() const {
return get_ref_value().to_os_specific_w();
}
/**
* Returns the variable's value, as a reference into the config variable
* itself. This is the internal method that implements get_value(), which

View File

@ -60,6 +60,8 @@ PUBLISHED:
INLINE Filename get_word(size_t n) const;
INLINE void set_word(size_t n, const Filename &value);
INLINE std::wstring __fspath__() const;
private:
void reload_cache();
INLINE const Filename &get_ref_value() const;