Skip to content

Instantly share code, notes, and snippets.

@larsiusprime
Created February 14, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsiusprime/37b20a5113e2c626845d5c67299b8886 to your computer and use it in GitHub Desktop.
Save larsiusprime/37b20a5113e2c626845d5c67299b8886 to your computer and use it in GitHub Desktop.
/**
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
Copy link

Klaim 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