File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,26 @@ std::string BaseSetting<StringMap>::to_string() const
433433 [](const auto & kvpair) { return kvpair.first + " =" + kvpair.second ; });
434434}
435435
436+ static Path parsePath (const AbstractSetting & s, const std::string & str)
437+ {
438+ if (str == " " )
439+ throw UsageError (" setting '%s' is a path and paths cannot be empty" , s.name );
440+ else
441+ return canonPath (str);
442+ }
443+
444+ template <>
445+ std::filesystem::path BaseSetting<std::filesystem::path>::parse(const std::string & str) const
446+ {
447+ return parsePath (*this , str);
448+ }
449+
450+ template <>
451+ std::string BaseSetting<std::filesystem::path>::to_string() const
452+ {
453+ return value.string ();
454+ }
455+
436456template class BaseSetting <int >;
437457template class BaseSetting <unsigned int >;
438458template class BaseSetting <long >;
@@ -445,14 +465,7 @@ template class BaseSetting<Strings>;
445465template class BaseSetting <StringSet>;
446466template class BaseSetting <StringMap>;
447467template class BaseSetting <std::set<ExperimentalFeature>>;
448-
449- static Path parsePath (const AbstractSetting & s, const std::string & str)
450- {
451- if (str == " " )
452- throw UsageError (" setting '%s' is a path and paths cannot be empty" , s.name );
453- else
454- return canonPath (str);
455- }
468+ template class BaseSetting <std::filesystem::path>;
456469
457470PathSetting::PathSetting (
458471 Config * options,
Original file line number Diff line number Diff line change @@ -134,6 +134,7 @@ DECLARE_CONFIG_SERIALISER(Strings)
134134DECLARE_CONFIG_SERIALISER(StringSet)
135135DECLARE_CONFIG_SERIALISER(StringMap)
136136DECLARE_CONFIG_SERIALISER(std::set<ExperimentalFeature>)
137+ DECLARE_CONFIG_SERIALISER(std::filesystem::path)
137138
138139template<typename T>
139140T BaseSetting<T>::parse(const std::string & str) const
Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ struct LoggerSettings : Config
5454 expression evaluation errors.
5555 )" };
5656
57- Setting<Path > jsonLogPath{
57+ Setting<std::filesystem::path > jsonLogPath{
5858 this ,
59- " " ,
59+ {} ,
6060 " json-log-path" ,
6161 R"(
6262 A file or unix socket to which JSON records of Nix's log output are
Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ void applyJSONLogger()
370370 if (!loggerSettings.jsonLogPath .get ().empty ()) {
371371 try {
372372 std::vector<std::unique_ptr<Logger>> loggers;
373- loggers.push_back (makeJSONLogger (std::filesystem::path ( loggerSettings.jsonLogPath .get () ), false ));
373+ loggers.push_back (makeJSONLogger (loggerSettings.jsonLogPath .get (), false ));
374374 try {
375375 logger = makeTeeLogger (std::move (logger), std::move (loggers));
376376 } catch (...) {
You can’t perform that action at this time.
0 commit comments