Skip to content

Commit fffbd7b

Browse files
committed
Return canonical path from directory::path
1 parent fa7cbe1 commit fffbd7b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

include/tmp/directory

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public:
7676
}
7777

7878
/// Returns the path of this directory
79-
/// @returns The full path of this directory
79+
/// @returns The canonical path of this directory
8080
operator const std::filesystem::path&() const noexcept {
8181
return pathobject;
8282
}
8383

8484
/// Returns the path of this directory
85-
/// @returns The full path of this directory
85+
/// @returns The canonical path of this directory
8686
const std::filesystem::path& path() const noexcept {
8787
return pathobject;
8888
}

src/create_directory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ fs::path create_directory(std::string_view prefix) {
9090
throw fs::filesystem_error("Cannot create a temporary directory", ec);
9191
}
9292

93-
return path;
93+
return fs::canonical(path);
9494
}
9595
} // namespace tmp::detail

tests/directory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ TEST(directory, create_with_prefix) {
3030
EXPECT_TRUE(fs::is_directory(tmpdir));
3131
EXPECT_TRUE(fs::equivalent(parent, fs::temp_directory_path()));
3232

33+
EXPECT_EQ(fs::canonical(tmpdir), tmpdir.path());
34+
3335
#ifdef _WIN32
3436
constexpr std::wstring_view actual_prefix = L"com.github.bugdea1er.tmp.";
3537
#else

0 commit comments

Comments
 (0)