Skip to content

Commit 3ccfb5c

Browse files
committed
FileWithDetails: delay resolution of absolute path until usage
1 parent e3d3533 commit 3ccfb5c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/filesettings.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class FileWithDetails
5050
{
5151
mPath = std::move(path);
5252
mPathSimplified = Path::simplifyPath(mPath);
53-
mPathAbsolute = Path::getAbsoluteFilePath(mPath);
53+
mPathAbsolute.clear();
5454
}
5555

5656
const std::string& path() const
@@ -65,6 +65,9 @@ class FileWithDetails
6565

6666
const std::string& abspath() const
6767
{
68+
// use delayed resolution as it will fail for files which do not exist
69+
if (mPathAbsolute.empty())
70+
mPathAbsolute = Path::getAbsoluteFilePath(mPath);
6871
return mPathAbsolute;
6972
}
7073

@@ -95,7 +98,7 @@ class FileWithDetails
9598
private:
9699
std::string mPath;
97100
std::string mPathSimplified;
98-
std::string mPathAbsolute;
101+
mutable std::string mPathAbsolute;
99102
Standards::Language mLang = Standards::Language::None;
100103
std::size_t mSize;
101104
std::size_t mFsFileId{0};

0 commit comments

Comments
 (0)