21#if defined(__linux__) || \
22 defined(__FreeBSD_kernel__) || \
24 defined(__unix__) || \
25 defined(__CYGWIN__) || \
35#include <util/pragma_push.def>
37#pragma warning(disable:4668)
39#pragma warning(disable : 5039)
47#include <util/pragma_pop.def>
59 std::string(
"realpath failed: ") + std::strerror(
errno));
61 std::string working_directory=
wd;
70 std::string working_directory(
narrow(buffer));
72 std::string working_directory(buffer);
77 return working_directory;
84 if(
chdir(path.c_str()) != 0)
86 std::string(
"chdir failed: ") + std::strerror(
errno));
139 std::string(
"Stat failed: ") + std::strerror(
errno));
148 std::string(
"Remove failed: ") + std::strerror(
errno));
161 const std::string &file_name)
165 file_name.size() > 1 && file_name[0] !=
'/' && file_name[0] !=
'\\' &&
178 if(!file_name.empty() && file_name[0] ==
'/')
204 if(
stat(path.c_str(), &
buf)!=0)
215 return _mkdir(path.c_str()) == 0;
218 return mkdir(path.c_str(), 0777) == 0;
236 return unlink(path.c_str()) == 0;
272 std::string(
"rename failed: ") + std::strerror(
errno));
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Thrown when some external system fails unexpectedly.
void set_current_path(const std::string &path)
Set working directory.
std::string get_current_working_directory()
bool file_exists(const std::string &path)
Check whether file with given path exists.
bool is_directory(const std::string &path)
void delete_directory(const std::string &path)
deletes all files in 'path' and then the directory itself
bool file_remove(const std::string &path)
C++17 will allow us to use std::filesystem::remove.
bool create_directory(const std::string &path)
Create a directory with given path C++17 will allow us to use std::filesystem::create_directory.
void file_rename(const std::string &old_path, const std::string &new_path)
Rename a file.
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
output_type narrow(input_type input)
Run-time checked narrowing cast.
std::wstring widen(const char *s)
std::wstring utf8_to_utf16_native_endian(const std::string &in)
Convert UTF8-encoded string to UTF-16 with architecture-native endianness.