Skip to content

Commit b0b9d78

Browse files
author
Samat Gaynutdinov
committed
refactor: use fs::weakly_canonical instead of current func
1 parent 64ba773 commit b0b9d78

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

server/src/Paths.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ namespace Paths {
108108
return fs::exists(path2) ? path2 : path1;
109109
}
110110

111-
fs::path getCanonicalPathIfExists(const std::string & filename) {
112-
fs::path p = fs::weakly_canonical(filename);
113-
return fs::exists(p) ? p : fs::path(filename);
114-
}
115-
116111
bool isPath(const std::string &possibleFilePath) noexcept {
117112
try {
118113
return fs::exists(possibleFilePath);

server/src/Paths.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ namespace Paths {
181181
}
182182

183183
fs::path getCCJsonFileFullPath(const std::string &filename, const fs::path &directory);
184-
fs::path getCanonicalPathIfExists(const std::string &filename);
185184

186185
bool isPath(const std::string &possibleFilePath) noexcept;
187186
//endregion

server/src/printers/NativeMakefilePrinter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ namespace printer {
681681

682682
fs::path NativeMakefilePrinter::getRelativePath(fs::path source, bool isCanonical) const {
683683
if (isCanonical) {
684-
source = Paths::getCanonicalPathIfExists(source);
684+
source = fs::weakly_canonical(source);
685685
}
686686

687687
for (const auto &[path, shellVariable] : pathToShellVariable) {
@@ -714,9 +714,8 @@ namespace printer {
714714
std::function<void(const std::string&, const std::string&)> declareFunc,
715715
bool shouldWriteToMap, bool isCanonical) {
716716
const fs::path relativePath = getRelativePath(path, isCanonical);
717-
fs::path canonical = Paths::getCanonicalPathIfExists(path);
718717
if (isCanonical) {
719-
path = canonical;
718+
path = fs::weakly_canonical(path);
720719
}
721720
declareFunc(variableName, relativePath.string());
722721
if (shouldWriteToMap) {

0 commit comments

Comments
 (0)