diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-11 11:18:35 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-11 11:18:35 +0100 |
| commit | 511faeef4f5b53fd0247dc0db1b8ccc1437af047 (patch) | |
| tree | b2d51496cbfd57f944a719ff71d89a3bf1f8441c /loader/filesystem.cpp | |
| parent | cff080f8dfcbf3b5729a38bbe5ba4bc80a1a4d79 (diff) | |
a
Diffstat (limited to 'loader/filesystem.cpp')
| -rw-r--r-- | loader/filesystem.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/loader/filesystem.cpp b/loader/filesystem.cpp new file mode 100644 index 00000000..8c62a9b3 --- /dev/null +++ b/loader/filesystem.cpp @@ -0,0 +1,35 @@ +#include "impl.hpp" +#include "compat/assert.hpp" +#include <Corrade/Containers/StringView.h> +#include <Corrade/Utility/Debug.h> +#include <Corrade/Utility/Implementation/ErrorString.h> +#ifdef _WIN32 +#include <Corrade/Containers/Array.h> +#include <Corrade/Utility/Unicode.h> +#include <direct.h> +#else +#include <unistd.h> +#endif + +namespace floormat::loader_detail { + +namespace Unicode = Corrade::Utility::Unicode; + +bool chdir(StringView pathname) +{ + int ret; +#ifdef _WIN32 + ret = _wchdir(Unicode::widen(pathname)); +#else + ret = chdir(pathname.data()); +#endif + if (ret) + { + Error err; + err << "chdir: can't change directory to" << pathname << Error::nospace << ':'; + Corrade::Utility::Implementation::printErrnoErrorString(err, errno); + } + return !ret; +} + +} // namespace floormat::loader_detail |
