@ -12,19 +12,12 @@ namespace VFS
{
{
FileSystemArchive : : FileSystemArchive ( const std : : filesystem : : path & path )
FileSystemArchive : : FileSystemArchive ( const std : : filesystem : : path & path )
: mBuiltIndex ( false )
: mPath ( path )
, mPath ( path )
{
}
void FileSystemArchive : : listResources ( FileMap & out )
{
if ( ! mBuiltIndex )
{
{
const auto str = mPath . u8string ( ) ;
const auto str = mPath . u8string ( ) ;
size_t prefix = str . size ( ) ;
std : : size_t prefix = str . size ( ) ;
if ( ! mPath . empty ( ) & & str [ prefix - 1 ] ! = ' \\ ' & & str [ prefix - 1 ] ! = ' / ' )
if ( prefix > 0 & & str [ prefix - 1 ] ! = ' \\ ' & & str [ prefix - 1 ] ! = ' / ' )
+ + prefix ;
+ + prefix ;
for ( const auto & i : std : : filesystem : : recursive_directory_iterator ( mPath ) )
for ( const auto & i : std : : filesystem : : recursive_directory_iterator ( mPath ) )
@ -32,29 +25,24 @@ namespace VFS
if ( std : : filesystem : : is_directory ( i ) )
if ( std : : filesystem : : is_directory ( i ) )
continue ;
continue ;
const auto & path = i . path ( ) ;
const std : : filesystem : : path & filePath = i . path ( ) ;
const std : : string proper = Files : : pathToUnicodeString ( path ) ;
const std : : string proper = Files : : pathToUnicodeString ( filePath ) ;
FileSystemArchiveFile file ( path ) ;
VFS : : Path : : Normalized searchable ( std : : string_view { proper } . substr ( prefix ) ) ;
VFS : : Path : : Normalized searchable ( std : : string_view { proper } . substr ( prefix ) ) ;
FileSystemArchiveFile file ( filePath ) ;
const auto inserted = mIndex . emplace ( std : : move ( searchable ) , std : : move ( file ) ) ;
const auto inserted = mIndex . emplace ( std : : move ( searchable ) , std : : move ( file ) ) ;
if ( ! inserted . second )
if ( ! inserted . second )
Log ( Debug : : Warning )
Log ( Debug : : Warning )
< < " Warning: f ound duplicate file for '" < < proper
< < " F ound duplicate file for '" < < proper
< < " ', please check your file system for two files with the same name in different cases. " ;
< < " ', please check your file system for two files with the same name in different cases. " ;
else
out [ inserted . first - > first ] = & inserted . first - > second ;
}
}
mBuiltIndex = true ;
}
}
else
void FileSystemArchive : : listResources ( FileMap & out )
{
{
for ( auto & [ k , v ] : mIndex )
for ( auto & [ k , v ] : mIndex )
out [ k ] = & v ;
out [ k ] = & v ;
}
}
}
bool FileSystemArchive : : contains ( Path : : NormalizedView file ) const
bool FileSystemArchive : : contains ( Path : : NormalizedView file ) const
{
{