diff --git a/p-filesystem.cc b/p-filesystem.cc index 9751e00..adef205 100644 --- a/p-filesystem.cc +++ b/p-filesystem.cc @@ -368,10 +368,20 @@ T_FSPath Filesystem::Cwd( ) noexcept // TODO windows version T_Buffer< char > buffer{ 256 }; +#if _WIN32 + auto req{ buffer.bytes( ) }; + do { + if ( req > buffer.bytes( ) ) { + buffer.resize( req + 1 ); + } + req = GetCurrentDirectory( buffer.bytes( ) , &buffer[ 0 ] ); + } while ( req > buffer.bytes( ) ); +#else while ( getcwd( &buffer[ 0 ] , buffer.bytes( ) ) == nullptr ) { assert( errno == ERANGE ); buffer.resize( buffer.size( ) + 256 ); } +#endif T_FSPath path{ &buffer[ 0 ] }; assert( path.isValid( ) );