36 extern "C" int _EXFUN(fileno, (FILE *));
48 struct _WDIR* __cdecl __MINGW_NOTHROW
49 _wopendir(
const wchar_t*);
50 struct _wdirent* __cdecl __MINGW_NOTHROW
52 int __cdecl __MINGW_NOTHROW
62 static_assert(std::is_same<CHRLib::ucs2_t, char16_t>::value,
63 "Wrong character type!");
64 static_assert(std::is_same<CHRLib::ucs4_t, char32_t>::value,
65 "Wrong character type!");
68 "Wrong character type!");
70 "Inconsist alignment between character types!");
78 u16_to_u(
const char16_t* u16str)
87 return std::move(str);
91 u_to_w(
const char* str)
98 wstr = std::wstring(reinterpret_cast<const wchar_t*>(
101 return std::move(wstr);
104 # error Unsupported platform found!
116 return ::open(filename, oflag);
120 return ::_wopen(u_to_w(filename).c_str(), oflag);
126 # error Unsupported platform found!
135 return ::open(filename, oflag, pmode);
139 return ::_wopen(u_to_w(filename).c_str(), oflag, pmode);
145 # error Unsupported platform found!
156 return ::open(u16_to_u(filename).c_str(), oflag);
162 return ::_wopen(reinterpret_cast<const wchar_t*>(filename), oflag);
164 # error Unsupported platform found!
175 return ::open(u16_to_u(filename).c_str(), oflag, pmode);
181 return ::_wopen(reinterpret_cast<const wchar_t*>(filename), oflag, pmode);
183 # error Unsupported platform found!
195 return std::fopen(filename, mode);
199 return ::_wfopen(u_to_w(filename).c_str(), u_to_w(mode).c_str());
205 # error Unsupported platform found!
218 return std::fopen(u16_to_u(filename).c_str(), u16_to_u(mode).c_str());
224 return ::_wfopen(reinterpret_cast<const wchar_t*>(filename),
225 reinterpret_cast<const wchar_t*>(mode));
227 # error Unsupported platform found!
239 if(
const auto file =
ufopen(filename,
"rb"))
246 # error Unsupported platform found!
254 if(
const auto file =
ufopen(filename, u
"rb"))
265 const auto dir(::opendir(path));
275 using namespace CHRLib;
280 const auto dir(::_wopendir(u_to_w(path).c_str()));
297 return ::getcwd(buf, size);
310 using namespace CHRLib;
315 const auto p(static_cast<ucs2_t*>(malloc((size + 1)
321 ::getcwd(reinterpret_cast<char*>(buf), size)));
328 memcpy(buf, p, ++len *
sizeof(
ucs2_t));
335 return reinterpret_cast<ucs2_t*
>(
336 ::_wgetcwd(reinterpret_cast<wchar_t*>(buf), size));
338 # error Unsupported platform found!
348 return ::chdir(path);
352 return path ? ::_wchdir(u_to_w(path).c_str()) : -1;
358 # error Unsupported platform found!
367 std::strcpy(path, cpath);
372 ::mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO);
376 return ::mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) == 0
384 return ::ftruncate(fileno(fp), ::off_t(size)) != 0;
386 return ::_chsize(_fileno(fp),
long(size));
388 # error Unsupported platform found!
412 #if YCL_DS || YCL_MINGW32
415 # error Unsupported platform found!
428 dir = path ? ::opendir(path) :
nullptr;
454 const auto p(std::strstr(path,
":/"));
456 return p && p != path && !std::strstr(p,
":/");
460 return !::PathIsRelativeW(u_to_w(path).c_str());
462 # error Unsupported platform found!
469 const char* p(std::strchr(path,
':'));
471 return !p ? 0 : p - path + 1;
476 namespace platform_ex