1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 20:53:52 +00:00

User data directory location getter.

This commit is contained in:
Bartosz Taudul 2019-12-28 18:16:45 +01:00
parent 36942a5ddb
commit 9e76ddb9fd
3 changed files with 18 additions and 4 deletions

View File

@ -117,7 +117,6 @@ const char* GetSavePath( const char* file )
const char* GetSavePath( const char* program, uint64_t time, const char* file, bool create ) const char* GetSavePath( const char* program, uint64_t time, const char* file, bool create )
{ {
assert( file && *file );
assert( program && *program ); assert( program && *program );
enum { Pool = 8 }; enum { Pool = 8 };
@ -195,9 +194,16 @@ const char* GetSavePath( const char* program, uint64_t time, const char* file, b
assert( status ); assert( status );
} }
const auto fsz = strlen( file ); if( file )
assert( sz + fsz < MaxPath ); {
memcpy( buf+sz, file, fsz+1 ); const auto fsz = strlen( file );
assert( sz + fsz < MaxPath );
memcpy( buf+sz, file, fsz+1 );
}
else
{
buf[sz] = '\0';
}
return buf; return buf;
} }

View File

@ -236,4 +236,10 @@ void UserData::Remove( const char* filename )
unlink( path ); unlink( path );
} }
const char* UserData::GetConfigLocation() const
{
assert( Valid() );
return GetSavePath( m_program.c_str(), m_time, nullptr, false );
}
} }

View File

@ -32,6 +32,8 @@ public:
void LoadAnnotations( std::vector<std::unique_ptr<Annotation>>& data ); void LoadAnnotations( std::vector<std::unique_ptr<Annotation>>& data );
void SaveAnnotations( const std::vector<std::unique_ptr<Annotation>>& data ); void SaveAnnotations( const std::vector<std::unique_ptr<Annotation>>& data );
const char* GetConfigLocation() const;
private: private:
FILE* OpenFile( const char* filename, bool write ); FILE* OpenFile( const char* filename, bool write );
void Remove( const char* filename ); void Remove( const char* filename );