mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Filter out invalid Windows filename characters.
Do so even on unix, to allow easy transfer of user config between different machines.
This commit is contained in:
parent
705a2fa3f4
commit
5c3095707a
@ -127,8 +127,64 @@ const char* GetSavePath( const char* program, uint64_t time, const char* file, b
|
||||
size_t sz;
|
||||
GetConfigDirectory( buf, sz );
|
||||
|
||||
const auto psz = strlen( program );
|
||||
assert( psz < 512 );
|
||||
char tmp[512];
|
||||
strcpy( tmp, program );
|
||||
for( size_t i=0; i<psz; i++ )
|
||||
{
|
||||
switch( tmp[i] )
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
case 25:
|
||||
case 26:
|
||||
case 27:
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 0x7F:
|
||||
case '<':
|
||||
case '>':
|
||||
case ':':
|
||||
case '"':
|
||||
case '/':
|
||||
case '\\':
|
||||
case '|':
|
||||
case '?':
|
||||
case '*':
|
||||
tmp[i] = '_';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 604800 = 7 days
|
||||
sz += sprintf( buf+sz, "/tracy/user/%c/%s/%" PRIu64 "/%" PRIu64 "/", program[0], program, uint64_t( time / 604800 ), time );
|
||||
sz += sprintf( buf+sz, "/tracy/user/%c/%s/%" PRIu64 "/%" PRIu64 "/", tmp[0], tmp, uint64_t( time / 604800 ), time );
|
||||
|
||||
if( create )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user