Skip to content

Commit 4624787

Browse files
committed
Fs: use os macros
1 parent 68c0659 commit 4624787

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/fs.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@
2424
*
2525
* -------------------------------------------------------------------------- */
2626

27+
#include "os.hpp"
2728
#include <climits>
2829
#include <cstdlib>
2930
#include <filesystem>
3031
#include <string>
31-
#if __APPLE__
32+
#if MCL_OS_MAC
3233
#include <libgen.h> // basename unix
3334
#include <pwd.h> // getpwuid
3435
#include <unistd.h> // getuid
3536
#endif
36-
#if _WIN32
37+
#if MCL_OS_WINDOWS
3738
#include <shlobj.h> // SHGetKnownFolderPath
3839
#endif
3940
#include "fs.hpp"
@@ -123,17 +124,17 @@ bool isProject(const std::string& s)
123124

124125
std::string getHomePath()
125126
{
126-
#if defined(__linux__) || defined(__FreeBSD__)
127+
#if MCL_OS_LINUX || MCL_OS_FREEBSD
127128

128129
char buf[PATH_MAX];
129130
snprintf(buf, PATH_MAX, "%s", getenv("HOME"));
130131

131-
#elif defined(_WIN32)
132+
#elif MCL_OS_WINDOWS
132133

133134
char buf[MAX_PATH];
134135
snprintf(buf, MAX_PATH, ".");
135136

136-
#elif defined(__APPLE__)
137+
#elif MCL_OS_MAC
137138

138139
char buf[PATH_MAX];
139140
struct passwd* pwd = getpwuid(getuid());
@@ -160,7 +161,7 @@ bool isRootDir(const std::string& s)
160161

161162
std::string getUpDir(const std::string& s)
162163
{
163-
#ifdef _WIN32
164+
#if MCL_OS_WINDOWS
164165

165166
// If root, let the user browse the drives list by returning "".
166167
if (isRootDir(s))
@@ -193,7 +194,7 @@ std::string join(const std::string& a, const std::string& b)
193194

194195
bool isValidFileName(const std::string& f)
195196
{
196-
#if _WIN32
197+
#if MCL_OS_WINDOWS
197198
const std::vector<char> forbidden = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
198199
#else
199200
const std::vector<char> forbidden = {'/', ':'}; // ':' not supported in macOS

0 commit comments

Comments
 (0)