Skip to content

Commit 1d7f86a

Browse files
committed
use .string() instead of .generic_string() where not needed
1 parent 7a3d309 commit 1d7f86a

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed

src/absolute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ std::string fs_absolute(std::string_view path, const bool expand_tilde)
3535
std::error_code ec;
3636

3737
if(auto a = Filesystem::absolute(ex, ec); !ec)
38-
return a.generic_string();
38+
return a.string();
3939

4040
fs_print_error(path, __func__, ec);
4141
return {};

src/platform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ std::string fs_get_cwd()
5454

5555
#if defined(HAVE_CXX_FILESYSTEM)
5656
if(auto s = Filesystem::current_path(ec); !ec) FFS_LIKELY
57-
return s.generic_string();
57+
return s.string();
5858
#elif defined(_WIN32)
5959
// windows.h https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory
6060
if(DWORD L = GetCurrentDirectoryW(0, nullptr); L > 0) {

src/pure.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool fs_is_absolute(std::string_view path)
8787
std::string fs_file_name(std::string_view path)
8888
{
8989
#ifdef HAVE_CXX_FILESYSTEM
90-
return Filesystem::path(path).filename().generic_string();
90+
return Filesystem::path(path).filename().string();
9191
#else
9292

9393
const auto i = path.find_last_of(fs_is_windows() ? "/\\" : "/");
@@ -104,7 +104,7 @@ std::string fs_root(std::string_view path)
104104
// root_path = root_name / root_directory
105105

106106
#ifdef HAVE_CXX_FILESYSTEM
107-
return Filesystem::path(path).root_path().generic_string();
107+
return Filesystem::path(path).root_path().string();
108108
#else
109109
if (std::string r = fs_root_name(path);
110110
r.empty())
@@ -133,7 +133,7 @@ std::string fs_root_name([[maybe_unused]] std::string_view path)
133133
std::string fs_stem(std::string_view path)
134134
{
135135
#ifdef HAVE_CXX_FILESYSTEM
136-
return Filesystem::path(path).filename().stem().generic_string();
136+
return Filesystem::path(path).filename().stem().string();
137137
#else
138138
std::string r = fs_file_name(path);
139139
// handle special case a/..
@@ -153,7 +153,7 @@ std::string fs_stem(std::string_view path)
153153
std::string fs_suffix(std::string_view path)
154154
{
155155
#ifdef HAVE_CXX_FILESYSTEM
156-
return Filesystem::path(path).filename().extension().generic_string();
156+
return Filesystem::path(path).filename().extension().string();
157157
#else
158158
const std::string p = fs_file_name(path);
159159
// find last dot
@@ -200,7 +200,7 @@ std::string fs_with_suffix(std::string_view path, std::string_view new_suffix)
200200
return fs_join(path, new_suffix);
201201

202202
#ifdef HAVE_CXX_FILESYSTEM
203-
return Filesystem::path(path).replace_extension(new_suffix).generic_string();
203+
return Filesystem::path(path).replace_extension(new_suffix).string();
204204
#else
205205
std::string const p = fs_parent(path);
206206

@@ -233,7 +233,7 @@ std::string fs_lexically_normal(std::string_view path){
233233

234234
std::string fs_make_preferred(std::string_view path){
235235
#ifdef HAVE_CXX_FILESYSTEM
236-
return Filesystem::path(path).make_preferred().generic_string();
236+
return Filesystem::path(path).make_preferred().string();
237237
#else
238238
fs_print_error(path, __func__, std::make_error_code(std::errc::function_not_supported));
239239
return {};

src/symlink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ std::string fs_read_symlink(std::string_view path)
116116
return fs_win32_final_path(path);
117117
#elif defined(HAVE_CXX_FILESYSTEM)
118118
if(auto p = Filesystem::read_symlink(path, ec); !ec) FFS_LIKELY
119-
return p.generic_string();
119+
return p.string();
120120
#else
121121

122122
// https://www.man7.org/linux/man-pages/man2/readlink.2.html

src/tempdir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ std::string fs_get_tempdir()
2323

2424
#ifdef HAVE_CXX_FILESYSTEM
2525
if(auto p = Filesystem::temp_directory_path(ec); !ec && !p.empty())
26-
return p.generic_string();
26+
return p.string();
2727
#endif
2828

2929
#if defined(_WIN32)

test/core/test_OnDisk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TestOnDisk : public testing::Test {
2626

2727
file = cwd + "/ffs_" + n + ".txt";
2828
ASSERT_TRUE(fs_touch(file));
29-
ASSERT_TRUE(fs_exists(file));
29+
ASSERT_TRUE(fs_is_file(file));
3030

3131
dir = cwd + "/ffs_" + n + "_dir";
3232
ASSERT_TRUE(fs_mkdir(dir));

test/core/test_env.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ auto t = fs_get_tempdir();
5656
EXPECT_FALSE(t.empty());
5757

5858
std::cout << "Temp directory " << t << "\n";
59-
EXPECT_TRUE(fs_exists(t));
59+
EXPECT_TRUE(fs_is_dir(t));
6060
}
6161

6262

@@ -95,7 +95,7 @@ auto t = fs_get_tempdir();
9595
EXPECT_FALSE(t.empty());
9696

9797
std::cout << "Temp directory " << t << "\n";
98-
EXPECT_TRUE(fs_exists(t));
98+
EXPECT_TRUE(fs_is_dir(t));
9999

100100
}
101101

test/core/test_permissions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ class TestPermissions : public testing::Test {
1111
std::string nowrite = "nonwritable.txt";
1212
void SetUp() override {
1313
ASSERT_TRUE(fs_touch(read));
14-
ASSERT_TRUE(fs_exists(read));
1514
ASSERT_TRUE(fs_is_file(read));
15+
1616
ASSERT_TRUE(fs_touch(noread));
17-
ASSERT_TRUE(fs_exists(noread));
1817
ASSERT_TRUE(fs_is_file(noread));
1918
if(!fs_is_file(nowrite)){
2019
ASSERT_TRUE(fs_touch(nowrite));

test/core/test_root.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if (!fs_is_windows())
1818
EXPECT_EQ(fs_root("c:"), "c:");
1919
EXPECT_EQ(fs_root("c:/a/b"), "c:/");
2020
EXPECT_EQ(fs_root("/etc"), "/");
21-
EXPECT_EQ(fs_root("\\etc"), "/");
22-
EXPECT_EQ(fs_root(R"(c:\)"), "c:/");
21+
EXPECT_EQ(fs_root("\\etc"), "\\");
22+
EXPECT_EQ(fs_root("c:\\"), "c:\\");
2323
EXPECT_EQ(fs_root("c:/"), "c:/");
24-
EXPECT_EQ(fs_root("\\"), "/");
24+
EXPECT_EQ(fs_root("\\"), "\\");
2525
}
2626

2727
TEST(TestRoot, Posix){

0 commit comments

Comments
 (0)