18 #if defined(__linux__) || \ 19 defined(__FreeBSD_kernel__) || \ 21 defined(__unix__) || \ 22 defined(__CYGWIN__) || \ 38 #define pclose _pclose 48 char *buf=
reinterpret_cast<char*
>(
malloc(
sizeof(
char)*bsize));
54 while(buf && getcwd(buf, bsize-1)==
nullptr && errno==ERANGE)
57 buf=
reinterpret_cast<char*
>(realloc(buf,
sizeof(
char)*bsize));
60 std::string working_directory=buf;
63 return working_directory;
69 void delete_directory_utf16(
const std::wstring &path)
71 std::wstring pattern=path + L
"\\*";
73 struct _wfinddata_t info;
74 intptr_t hFile=_wfindfirst(pattern.c_str(), &info);
79 if(wcscmp(info.name, L
".")==0 || wcscmp(info.name, L
"..")==0)
81 std::wstring sub_path=path+L
"\\"+info.name;
82 if(info.attrib & _A_SUBDIR)
83 delete_directory_utf16(sub_path);
85 DeleteFileW(sub_path.c_str());
87 while(_wfindnext(hFile, &info)==0);
89 RemoveDirectoryW(path.c_str());
100 DIR *dir=opendir(path.c_str());
104 while((ent=readdir(dir))!=
nullptr)
107 if(strcmp(ent->d_name,
".")==0 || strcmp(ent->d_name,
"..")==0)
110 std::string sub_path=path+
"/"+ent->d_name;
113 stat(sub_path.c_str(), &stbuf);
115 if(S_ISDIR(stbuf.st_mode))
118 remove(sub_path.c_str());
129 const std::string &directory,
130 const std::string &file_name)
133 return (file_name.size()>1 &&
136 file_name : directory+
"\\"+file_name;
138 return (!file_name.empty() && file_name[0]==
'/') ?
139 file_name : directory+
"/"+file_name;
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
std::string get_current_working_directory()
void delete_directory(const std::string &path)
deletes all files in 'path' and then the directory itself
std::wstring utf8_to_utf16_little_endian(const std::string &in)