#pragma once
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
namespace opencc {
inline char* portable_getcwd() {
#ifdef _WIN32
return _getcwd(nullptr, 0);
#else
return getcwd(nullptr, 0);
#endif
}
inline int portable_chdir(const char* path) {
#ifdef _WIN32
return _chdir(path);
#else
return chdir(path);
#endif
}
inline void portable_putenv(const char* key, const char* value) {
#ifdef _WIN32
_putenv_s(key, value);
#else
setenv(key, value, 1);
#endif
}
inline void portable_unsetenv(const char* key) {
#ifdef _WIN32
_putenv_s(key, "");
#else
unsetenv(key);
#endif
}
}