Skip to content

Commit f83311c

Browse files
committed
fix conversion from std::filesystem::path to agi::fs::path
1 parent 6c0bab6 commit f83311c

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

libaegisub/osx/path.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
#include <libaegisub/path.h>
1818
#include <libaegisub/util_osx.h>
1919

20+
namespace sfs = std::filesystem;
21+
2022
namespace agi {
2123
void Path::FillPlatformSpecificPaths() {
22-
std::filesystem::path app_support = agi::util::GetApplicationSupportDirectory();
23-
SetToken("?user", app_support/"Aegisub");
24-
SetToken("?local", app_support/"Aegisub");
24+
agi::fs::path user_dir = agi::fs::path(sfs::path(agi::util::GetApplicationSupportDirectory()))/"Aegisub";
25+
SetToken("?user", user_dir);
26+
SetToken("?local", user_dir);
2527
SetToken("?data", agi::util::GetBundleSharedSupportDirectory());
2628
SetToken("?dictionary", Decode("?data/dictionaries"));
27-
SetToken("?temp", std::filesystem::temp_directory_path());
29+
SetToken("?temp", agi::fs::path(sfs::temp_directory_path()));
2830
}
2931
}

libaegisub/unix/path.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
namespace sfs = std::filesystem;
2424

2525
namespace {
26-
sfs::path home_dir() {
26+
agi::fs::path home_dir() {
2727
const char *env = getenv("HOME");
28-
if (env) return env;
28+
if (env) return agi::fs::path(sfs::path(env));
2929

3030
if ((env = getenv("USER")) || (env = getenv("LOGNAME"))) {
3131
if (passwd *user_info = getpwnam(env))
32-
return user_info->pw_dir;
32+
return agi::fs::path(sfs::path(user_info->pw_dir));
3333
}
3434

3535
throw agi::EnvironmentError("Could not get home directory. Make sure HOME is set.");
3636
}
3737

3838
#ifdef APPIMAGE_BUILD
39-
sfs::path data_dir() {
39+
agi::fs::path data_dir() {
4040
char *exe = realpath("/proc/self/exe", NULL);
4141
if (!exe) return "";
4242

@@ -45,30 +45,29 @@ sfs::path data_dir() {
4545

4646
if (p.filename() == "bin") {
4747
// assume unix prefix layout
48-
return p.parent_path()/"share";
48+
return agi::fs::path(p.parent_path()/"share");
4949
}
5050

51-
return p;
51+
return agi::fs::path(p);
5252
}
5353
#endif
5454
}
5555

5656
namespace agi {
5757
void Path::FillPlatformSpecificPaths() {
58-
sfs::path dotdir = home_dir()/".aegisub";
59-
SetToken("?user", dotdir.string());
60-
SetToken("?local", dotdir.string());
58+
agi::fs::path dotdir = home_dir()/".aegisub";
59+
SetToken("?user", dotdir);
60+
SetToken("?local", dotdir);
6161

6262
#ifdef APPIMAGE_BUILD
63-
sfs::path data = data_dir();
64-
if (data == "") data = dotdir.string();
65-
SetToken("?data", data.string());
63+
agi::fs::path data = data_dir();
64+
SetToken("?data", (data == "") ? dotdir : data);
6665
SetToken("?dictionary", Decode("?data/dictionaries"));
6766
#else
6867
SetToken("?data", P_DATA);
6968
SetToken("?dictionary", "/usr/share/hunspell");
7069
#endif
7170

72-
SetToken("?temp", sfs::temp_directory_path().string());
71+
SetToken("?temp", agi::fs::path(sfs::temp_directory_path()));
7372
}
7473
}

0 commit comments

Comments
 (0)