Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
sys_create_dir : string -> mode:int -> void
<doc>Create a directory with the specified rights</doc>
**/
bool _hx_std_sys_create_dir( String path, int mode )
{
printf("_hx_std_sys_create_dir()\n");
#ifdef EPPC
return true;
#else
hx::EnterGCFreeZone();
#ifdef NEKO_WINDOWS
//bool err = mkdir(path.__s);
std::wstring temp = _Win32Utf8ToUtf16( path.__s );
bool err = _wmkdir( temp.c_str() );
#else
bool err = mkdir(path.__s,mode);
#endif
hx::ExitGCFreeZone();
return !err;
#endif
}
#ifdef NEKO_WINDOWS
// Do not use outside win32
inline std::wstring _Win32Utf8ToUtf16(const std::string& str)
{
printf("TESTING\n");
std::wstring convertedString;
int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0);
if( requiredSize > 0 )
{
convertedString.resize(requiredSize);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &convertedString[0], requiredSize);
convertedString.pop_back(); //remove NULL terminator
}
return convertedString;
}
#endif
@Klaim

This comment has been minimized.

Copy link

commented Feb 14, 2018

Line 14 can be removed.
The printf calls too.
temp could have been const.
Otherwise, Looks Good To Me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.