Trace-specific save path retrieval.

This commit is contained in:
Bartosz Taudul 2019-07-26 22:46:51 +02:00
parent 3ec1771f5a
commit 34cc7183d0
2 changed files with 32 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <assert.h> #include <assert.h>
#include <inttypes.h>
#include <string> #include <string>
#include <string.h> #include <string.h>
@ -109,4 +110,32 @@ const char* GetSavePath( const char* file )
return buf; return buf;
} }
const char* GetSavePath( const char* program, uint64_t time, const char* file, bool create )
{
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 );
// 604800 = 7 days
sz += sprintf( buf+sz, "/tracy/user/%c/%s/%" PRIu64 "/%" PRIu64 "/", program[0], program, uint64_t( time / 604800 ), time );
if( create )
{
auto status = CreateDirStruct( buf );
assert( status );
}
const auto fsz = strlen( file );
assert( sz + fsz < MaxPath );
memcpy( buf+sz, file, fsz+1 );
return buf;
}
} }

View File

@ -1,10 +1,13 @@
#ifndef __TRACYSTORAGE_HPP__ #ifndef __TRACYSTORAGE_HPP__
#define __TRACYSTORAGE_HPP__ #define __TRACYSTORAGE_HPP__
#include <stdint.h>
namespace tracy namespace tracy
{ {
const char* GetSavePath( const char* file ); const char* GetSavePath( const char* file );
const char* GetSavePath( const char* program, uint64_t time, const char* file, bool create );
} }