From 511faeef4f5b53fd0247dc0db1b8ccc1437af047 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Nov 2022 11:18:35 +0100 Subject: a --- loader/filesystem.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 loader/filesystem.cpp (limited to 'loader/filesystem.cpp') 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 +#include +#include +#ifdef _WIN32 +#include +#include +#include +#else +#include +#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 -- cgit v1.2.3