diff --git a/update/build/win32/update.vcxproj b/update/build/win32/update.vcxproj index 46ed6aa9..45e39838 100644 --- a/update/build/win32/update.vcxproj +++ b/update/build/win32/update.vcxproj @@ -138,6 +138,7 @@ + @@ -183,6 +184,7 @@ + diff --git a/update/build/win32/update.vcxproj.filters b/update/build/win32/update.vcxproj.filters index 95dbfec5..5f61cff9 100644 --- a/update/build/win32/update.vcxproj.filters +++ b/update/build/win32/update.vcxproj.filters @@ -13,6 +13,9 @@ {2ec8dc96-8501-481f-8620-7f33bd8b2164} + + {74a14f40-f52d-41c1-8b19-1f8bf2a7c9c7} + @@ -126,6 +129,9 @@ server + + getopt + @@ -287,5 +293,8 @@ server + + getopt + \ No newline at end of file diff --git a/update/src/update.cpp b/update/src/update.cpp index 66cbb442..71db378e 100644 --- a/update/src/update.cpp +++ b/update/src/update.cpp @@ -13,6 +13,7 @@ #include "../../server/TracyVersion.hpp" #include "../../server/TracyWorker.hpp" #include "../../zstd/zstd.h" +#include "../../getopt/getopt.h" #ifdef __CYGWIN__ # define ftello64(x) ftello(x) @@ -24,10 +25,10 @@ void Usage() { - printf( "Usage: update [--hc|--extreme] input.tracy output.tracy\n\n" ); - printf( " --hc: enable LZ4HC compression\n" ); - printf( " --extreme: enable extreme LZ4HC compression (very slow)\n" ); - printf( " --zstd level: use Zstd compression with given compression level\n" ); + printf( "Usage: update [options] input.tracy output.tracy\n\n" ); + printf( " -h: enable LZ4HC compression\n" ); + printf( " -e: enable extreme LZ4HC compression (very slow)\n" ); + printf( " -z level: use Zstd compression with given compression level\n" ); exit( 1 ); } @@ -44,38 +45,35 @@ int main( int argc, char** argv ) tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast; int zstdLevel = 1; - if( argc != 3 && argc != 4 && argc != 5 ) Usage(); - if( argc == 4 ) + int c; + while( ( c = getopt( argc, argv, "hez:" ) ) != -1 ) { - if( strcmp( argv[1], "--hc" ) == 0 ) + switch( c ) { + case 'h': clev = tracy::FileWrite::Compression::Slow; - } - else if( strcmp( argv[1], "--extreme" ) == 0 ) - { + break; + case 'e': clev = tracy::FileWrite::Compression::Extreme; - } - else - { + break; + case 'z': + clev = tracy::FileWrite::Compression::Zstd; + zstdLevel = atoi( optarg ); + if( zstdLevel > ZSTD_maxCLevel() || zstdLevel < ZSTD_minCLevel() ) + { + printf( "Available Zstd compression levels range: %i - %i\n", ZSTD_minCLevel(), ZSTD_maxCLevel() ); + exit( 1 ); + } + break; + default: Usage(); + break; } - argv++; - } - if( argc == 5 ) - { - if( strcmp( argv[1], "--zstd" ) != 0 ) Usage(); - clev = tracy::FileWrite::Compression::Zstd; - zstdLevel = atoi( argv[2] ); - if( zstdLevel > ZSTD_maxCLevel() || zstdLevel < ZSTD_minCLevel() ) - { - printf( "Available Zstd compression levels range: %i - %i\n", ZSTD_minCLevel(), ZSTD_maxCLevel() ); - exit( 1 ); - } - argv += 2; } + if( argc - optind != 2 ) Usage(); - const char* input = argv[1]; - const char* output = argv[2]; + const char* input = argv[optind]; + const char* output = argv[optind+1]; printf( "Loading...\r" ); fflush( stdout );