@ -203,24 +203,16 @@ public:
void ToWidePath ( const std : : string & value , std : : wstring & target ) {
wchar_t buffer [ MAX_PATH ] ;
MultiByteToWideChar ( CP_ ACP , 0 , value . c_str ( ) , - 1 , buffer , MAX_PATH ) ;
MultiByteToWideChar ( CP_ UTF8 , 0 , value . c_str ( ) , - 1 , buffer , MAX_PATH ) ;
target = buffer ;
}
void ToNarrowPath ( const std : : wstring & value , std : : string & target ) {
char buffer [ MAX_PATH ] ;
WideCharToMultiByte ( CP_ ACP , 0 , value . c_str ( ) , - 1 , buffer , MAX_PATH , NULL , NULL ) ;
WideCharToMultiByte ( CP_ UTF8 , 0 , value . c_str ( ) , - 1 , buffer , MAX_PATH , NULL , NULL ) ;
target = buffer ;
}
std : : string GetCurrentDir ( )
{
CHAR path [ MAX_PATH ] ;
: : GetModuleFileNameA ( : : GetModuleHandleA ( NULL ) , path , MAX_PATH ) ;
* strrchr ( path , ' \\ ' ) = 0 ;
return std : : string ( path ) ;
}
std : : wstring GetCurrentDirW ( )
{
WCHAR path [ MAX_PATH ] ;
@ -229,6 +221,13 @@ std::wstring GetCurrentDirW()
return std : : wstring ( path ) ;
}
std : : string GetCurrentDir ( )
{
std : : string path ;
ToNarrowPath ( GetCurrentDirW ( ) , path ) ;
return path ;
}
std : : string & ModifyPath ( std : : string & path )
{
if ( path [ 0 ] = = ' / ' | | path [ 0 ] = = ' \\ ' ) {
@ -764,14 +763,16 @@ uint64_t Win32Env::NowMicros()
static Status CreateDirInner ( const std : : string & dirname )
{
Status sRet ;
DWORD attr = : : GetFileAttributes ( dirname . c_str ( ) ) ;
std : : wstring dirnameW ;
ToWidePath ( dirname , dirnameW ) ;
DWORD attr = : : GetFileAttributesW ( dirnameW . c_str ( ) ) ;
if ( attr = = INVALID_FILE_ATTRIBUTES ) { // doesn't exist:
std : : size_t slash = dirname . find_last_of ( " \\ " ) ;
if ( slash ! = std : : string : : npos ) {
sRet = CreateDirInner ( dirname . substr ( 0 , slash ) ) ;
if ( ! sRet . ok ( ) ) return sRet ;
}
BOOL result = : : CreateDirectory ( dirname . c_str ( ) , NULL ) ;
BOOL result = : : CreateDirectory W ( dirname W . c_str ( ) , NULL ) ;
if ( result = = FALSE ) {
sRet = Status : : IOError ( dirname , " Could not create directory. " ) ;
return sRet ;