1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Move config directory retrieval to a separate function.

This commit is contained in:
Bartosz Taudul 2019-07-26 22:42:50 +02:00
parent c1b70c6519
commit 3ec1771f5a

View File

@ -50,18 +50,11 @@ static bool CreateDirStruct( const std::string& path )
return true; return true;
} }
const char* GetSavePath( const char* file ) static void GetConfigDirectory( char* buf, size_t& sz )
{ {
enum { Pool = 8 };
enum { MaxPath = 512 };
static char bufpool[Pool][MaxPath];
static int bufsel = 0;
char* buf = bufpool[bufsel];
bufsel = ( bufsel + 1 ) % Pool;
#ifdef _WIN32 #ifdef _WIN32
auto path = getenv( "APPDATA" ); auto path = getenv( "APPDATA" );
auto sz = strlen( path ); sz = strlen( path );
memcpy( buf, path, sz ); memcpy( buf, path, sz );
for( size_t i=0; i<sz; i++ ) for( size_t i=0; i<sz; i++ )
@ -73,7 +66,6 @@ const char* GetSavePath( const char* file )
} }
#else #else
auto path = getenv( "XDG_CONFIG_HOME" ); auto path = getenv( "XDG_CONFIG_HOME" );
size_t sz;
if( path && *path ) if( path && *path )
{ {
sz = strlen( path ); sz = strlen( path );
@ -90,6 +82,19 @@ const char* GetSavePath( const char* file )
sz += 8; sz += 8;
} }
#endif #endif
}
const char* GetSavePath( const char* file )
{
enum { Pool = 8 };
enum { MaxPath = 512 };
static char bufpool[Pool][MaxPath];
static int bufsel = 0;
char* buf = bufpool[bufsel];
bufsel = ( bufsel + 1 ) % Pool;
size_t sz;
GetConfigDirectory( buf, sz );
memcpy( buf+sz, "/tracy/", 8 ); memcpy( buf+sz, "/tracy/", 8 );
sz += 7; sz += 7;