diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/build_res_list/build_res_list.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/build_res_list/build_res_list.cpp')
| -rw-r--r-- | utils/build_res_list/build_res_list.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/utils/build_res_list/build_res_list.cpp b/utils/build_res_list/build_res_list.cpp new file mode 100644 index 0000000..7a1ba5b --- /dev/null +++ b/utils/build_res_list/build_res_list.cpp @@ -0,0 +1,73 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// build_res_list.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include <stdio.h> +#include <io.h> +#include <string.h> + + +int PrintUsage() +{ + printf( "build_res_list <source directory> <output filename>\n" ); + return 1; +} + + +void ScanDirectories_R( const char *pFullDir, const char *pRelDir, FILE *fp ) +{ + char spec[512]; + _snprintf( spec, sizeof( spec ), "%s\\*.*", pFullDir ); + + printf( "\"%s\"\n", pFullDir ); + + _finddata_t findInfo; + long handle = _findfirst( spec, &findInfo ); + if ( handle != -1 ) + { + do + { + if ( !stricmp( findInfo.name, "." ) || !stricmp( findInfo.name, ".." ) ) + continue; + + char fullName[512], relName[512]; + _snprintf( fullName, sizeof( fullName ), "%s\\%s", pFullDir, findInfo.name ); + _snprintf( relName, sizeof( relName ), "%s%s%s", pRelDir, (pRelDir[0] == 0) ? "" : "\\", findInfo.name ); + + if ( findInfo.attrib & _A_SUBDIR ) + { + ScanDirectories_R( fullName, relName, fp ); + } + else + { + fprintf( fp, "\"%s\"\n", relName ); + } + } while ( !_findnext( handle, &findInfo ) ); + + _findclose( handle ); + } +} + + +int main(int argc, char* argv[]) +{ + if ( argc < 3 ) + return PrintUsage(); + + const char *pSourceDir = argv[1]; + const char *pOutputFilename = argv[2]; + + FILE *fp = fopen( pOutputFilename, "wt" ); + if ( !fp ) + { + printf( "Can't open %s for writing.\n", pOutputFilename ); + return PrintUsage(); + } + + ScanDirectories_R( pSourceDir, "", fp ); + + fclose( fp ); + return 0; +} + |