Filesystem abstraction prototype - Windows version of Cwd()
This commit is contained in:
parent
2d3f98aba1
commit
852573432f
1 changed files with 10 additions and 0 deletions
|
@ -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( ) );
|
||||
|
|
Loading…
Reference in a new issue