Skip to content

Commit

Permalink
fix issue where mount as root / didn't work when mounting folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasgustavsson committed Jan 4, 2024
1 parent 68ea183 commit e9672c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assetsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Licensing information can be found at the end of the file.
------------------------------------------------------------------------------
assetsys.h - v1.4 - File system abstraction to read from zip-files, for C/C++.
assetsys.h - v1.5 - File system abstraction to read from zip-files, for C/C++.
Do this:
#define ASSETSYS_IMPLEMENTATION
Expand Down Expand Up @@ -5754,7 +5754,7 @@ static void assetsys_internal_collate_directories( assetsys_t* sys, struct asset
if( file->parent < 0 )
{
char* file_path = assetsys_internal_dirname( assetsys_internal_get_string( sys, file->path ) ) ;
ASSETSYS_U64 handle = strpool_inject( &sys->strpool, file_path, (int) strlen( file_path ) - 1 );
ASSETSYS_U64 handle = strpool_inject( &sys->strpool, file_path, file_path[0] == '/' && file_path[1] == '\0' ? 1 : (int) strlen( file_path ) - 1 );
for( int j = 0; j < sys->collated_count; ++j )
{
struct assetsys_internal_collated_t* dir = &sys->collated[ j ];
Expand Down Expand Up @@ -5807,7 +5807,7 @@ static void assetsys_internal_recurse_directories( assetsys_t* sys, int const co
if( stat( sys->temp, &s ) == 0 )
{
strcpy( sys->temp, assetsys_internal_get_string( sys, mount->mounted_as ) );
strcat( sys->temp, "/" );
if( *sys->temp && sys->temp[ strlen( sys->temp ) - 1 ] != '/' ) strcat( sys->temp, "/" );
strcat( sys->temp, file_path );
strcat( sys->temp, *file_path == '\0' ? "" : "/" );
strcat( sys->temp, name );
Expand Down Expand Up @@ -5844,7 +5844,7 @@ static void assetsys_internal_recurse_directories( assetsys_t* sys, int const co
if( stat( sys->temp, &s ) == 0 )
{
strcpy( sys->temp, assetsys_internal_get_string( sys, mount->mounted_as ) );
strcat( sys->temp, "/" );
if( *sys->temp && sys->temp[ strlen( sys->temp ) - 1 ] != '/' ) strcat( sys->temp, "/" );
strcat( sys->temp, folder_path );
strcat( sys->temp, *folder_path == '\0' ? "" : "/" );
strcat( sys->temp, name );
Expand Down Expand Up @@ -6519,6 +6519,7 @@ int main( int argc, char** argv ) {
Rob Loach (assetsys_mount_from_memory)
revision history:
1.5 fix issue where mount as root "/" didn't work when mounting folder
1.4 allow mounting from memory
1.3 allow absolute paths when mounting, update docs for mount as root
1.2 asserts with message, eliminated a frequent small allocation
Expand Down

0 comments on commit e9672c5

Please sign in to comment.