Skip to content

Commit f3694e3

Browse files
committed
chore: Config has workingDir
1 parent 1f9bf64 commit f3694e3

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

include/mrdox/Config.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ class MRDOX_VISIBLE
111111

112112
//--------------------------------------------
113113

114+
/** Full path to the working directory
115+
116+
The working directory is used to calculate
117+
full paths from relative paths.
118+
119+
This string will always be POSIX style
120+
and have a trailing directory separator.
121+
*/
122+
std::string_view workingDir;
123+
114124
/** A string holding the complete configuration YAML.
115125
*/
116126
std::string_view configYaml;

source/ConfigImpl.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,33 @@ namespace mrdox {
6969
Error
7070
ConfigImpl::
7171
construct(
72-
llvm::StringRef workingDir,
73-
llvm::StringRef configYamlStr,
74-
llvm::StringRef extraYamlStr)
72+
llvm::StringRef workingDirArg,
73+
llvm::StringRef configYamlArg,
74+
llvm::StringRef extraYamlArg)
7575
{
7676
namespace fs = llvm::sys::fs;
7777
namespace path = llvm::sys::path;
7878

7979
// calculate working directory
8080
llvm::SmallString<64> s;
81-
if(workingDir.empty())
81+
if(workingDirArg.empty())
8282
{
8383
if(auto ec = fs::current_path(s))
8484
return Error(ec);
8585
}
8686
else
8787
{
88-
s = workingDir;
88+
s = workingDirArg;
8989
}
9090
path::remove_dots(s, true);
9191
makeDirsy(s);
9292
convert_to_slash(s);
9393
workingDir_ = s;
94+
workingDir = std::string_view(
95+
workingDir_.data(), workingDir_.size());
9496

95-
configYamlStr_ = configYamlStr;
96-
extraYamlStr_ = extraYamlStr;
97+
configYamlStr_ = configYamlArg;
98+
extraYamlStr_ = extraYamlArg;
9799

98100
configYaml = configYamlStr_;
99101
extraYaml = extraYamlStr_;
@@ -138,7 +140,7 @@ normalizedPath(
138140
llvm::SmallString<0> result;
139141
if(! path::is_absolute(pathName))
140142
{
141-
result = workingDir();
143+
result = workingDir;
142144
path::append(result, path::Style::posix, pathName);
143145
path::remove_dots(result, true, path::Style::posix);
144146
}

source/ConfigImpl.hpp

-11
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ class ConfigImpl
8181
return concurrency_ != 1;
8282
}
8383

84-
/** Return the full path to the working directory.
85-
86-
The returned path will always be POSIX
87-
style and have a trailing separator.
88-
*/
89-
llvm::StringRef
90-
workingDir() const noexcept
91-
{
92-
return workingDir_;
93-
}
94-
9584
/** Return the full path to the source root directory.
9685
9786
The returned path will always be POSIX

0 commit comments

Comments
 (0)