Skip to content

Commit 2eb8ed6

Browse files
committed
Path > fs::path
1 parent 413b39a commit 2eb8ed6

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/argv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void Game::handleArgv(int argc, char* argv[]) {
3434
{ 'd', "--desc", printDescription },
3535
};
3636

37-
std::optional<Path> altSaveDir;
37+
std::optional<fs::path> altSaveDir;
3838
for (size_t i = 1; i < argc; i++) {
3939
std::string arg = argv[i];
4040
if (arg.starts_with("--")) {

src/basics.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
int screenWidth = 700;
55
int screenHeight = 500;
66

7-
Path const resourceDir = [] -> Path {
8-
Path const exeDir = GetApplicationDirectory();
7+
fs::path const resourceDir = [] -> fs::path {
8+
fs::path const exeDir = GetApplicationDirectory();
99
#ifdef _WIN32
1010
return exeDir;
1111
#elif defined(__linux__)
1212
if (exeDir.string().starts_with("/usr") &&
1313
DirectoryExists("/usr/share/" PROJECT_NAME "/resources")
14-
) return Path{"/usr/share"}/PROJECT_NAME/"resources";
14+
) return fs::path{"/usr/share"}/PROJECT_NAME/"resources";
1515
#endif
1616
return exeDir/"resources";
1717
}();
1818

19-
Path saveDir = [] -> Path {
20-
Path ret = Path{GetApplicationDirectory()} / "save";
19+
fs::path saveDir = [] -> fs::path {
20+
fs::path ret = fs::path{GetApplicationDirectory()} / "save";
2121
#ifdef _WIN32
22-
Path appData = std::getenv("APPDATA");
22+
fs::path appData = std::getenv("APPDATA");
2323
ret = appData/PROJECT_NAME;
2424
#elif defined(__linux__)
25-
Path homeDir = std::getenv("HOME");
25+
fs::path homeDir = std::getenv("HOME");
2626
ret = homeDir/".local"/"share"/PROJECT_NAME;
2727
#endif
2828
if (!DirectoryExists(ret.string().c_str()))

src/basics.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
int constexpr START_SCREEN_WIDTH = 700;
55
int constexpr START_SCREEN_HEIGHT = 500;
66

7-
using Path = std::filesystem::path;
8-
extern Path const resourceDir;
9-
extern Path saveDir;
7+
namespace fs = std::filesystem;
8+
extern fs::path const resourceDir;
9+
extern fs::path saveDir;

src/game.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Game::~Game() {
3838
localTime->tm_min,
3939
localTime->tm_sec
4040
);
41-
Path logsDir = saveDir/"logs";
41+
fs::path logsDir = saveDir/"logs";
4242
if (!DirectoryExists(logsDir.string().c_str())) MakeDirectory(logsDir.string().c_str());
4343
SaveFileText((logsDir/logFileName).string().c_str(), m_logs.str().c_str());
4444
}

src/resource-manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ void ResourceManager::uninitialize() {
2525
}
2626
}
2727

28-
bool ResourceManager::loadImage(std::string id, Path relativePath, LoadImageCallback manipulator) {
29-
Path const fullPath = resourceDir / relativePath;
28+
bool ResourceManager::loadImage(std::string id, fs::path relativePath, LoadImageCallback manipulator) {
29+
fs::path const fullPath = resourceDir / relativePath;
3030
if (!FileExists(fullPath.string().c_str())) {
3131
TraceLog(LOG_WARNING, "Image file does not exist [%s]: %s", id.c_str(), fullPath.string().c_str());
3232
return false;
@@ -48,7 +48,7 @@ bool ResourceManager::loadImage(std::string id, Path relativePath, LoadImageCall
4848
m_images[id] = image;
4949
return true;
5050
}
51-
bool ResourceManager::loadTexture(std::string id, Path relativePath, LoadImageCallback manipulator) {
51+
bool ResourceManager::loadTexture(std::string id, fs::path relativePath, LoadImageCallback manipulator) {
5252
if (!loadImage(id, relativePath, manipulator)) {
5353
TraceLog(LOG_WARNING, "Texture of id %s failed to load", id.c_str());
5454
return false;

src/resource-manager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class ResourceManager {
1717
void initialize();
1818
void uninitialize();
1919

20-
bool loadImage(std::string id, Path relativePath, LoadImageCallback manipulator = dummyImageManipulator);
21-
bool loadTexture(std::string id, Path relativePath, LoadImageCallback manipulator = dummyImageManipulator);
20+
bool loadImage(std::string id, fs::path relativePath, LoadImageCallback manipulator = dummyImageManipulator);
21+
bool loadTexture(std::string id, fs::path relativePath, LoadImageCallback manipulator = dummyImageManipulator);
2222

2323
Image const& getImage(std::string id) const;
2424
Texture2D const& getTexture(std::string id) const;

0 commit comments

Comments
 (0)