From 636807e68a85a978473764d171ed0c7cc36f9be6 Mon Sep 17 00:00:00 2001 From: lbavoil Date: Thu, 15 Mar 2018 11:08:34 +0100 Subject: HBAO+ 4.0.0.23740451 --- build/tools/Stringify/Stringify.cpp | 48 ++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'build/tools/Stringify/Stringify.cpp') diff --git a/build/tools/Stringify/Stringify.cpp b/build/tools/Stringify/Stringify.cpp index ea3fe68..38bd512 100644 --- a/build/tools/Stringify/Stringify.cpp +++ b/build/tools/Stringify/Stringify.cpp @@ -1,8 +1,8 @@ -// Stringify.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" - +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include int main(int argc, char* argv[]) { @@ -16,7 +16,15 @@ int main(int argc, char* argv[]) const char* pVariableName = argv[2]; const char *pFilenameOut = argv[3]; - FILE *fpIn = fopen(pFilenameIn, "r"); + FILE *fpIn = fopen(pFilenameIn, "rb"); + fseek(fpIn, 0, SEEK_END); + long fileSize = ftell(fpIn); + fseek(fpIn, 0, SEEK_SET); + std::vector entireFile(fileSize); + fread(entireFile.data(), 1, (size_t)fileSize, fpIn); + entireFile.push_back(0); + fseek(fpIn, 0, SEEK_SET); + if (!fpIn) { fprintf(stderr, "Error: Failed to open %s\n", pFilenameIn); @@ -30,17 +38,29 @@ int main(int argc, char* argv[]) exit(1); } - fprintf(fpOut, "static const char* %s =\n", pVariableName); + // fprintf(fpOut, "// static const char* %s =\n", pVariableName); + // + // char row[1024]; + // while (fgets(row, sizeof(row), fpIn)) + // { + // row[strlen(row) - 1] = row[strlen(row) - 2] = 0; // remove \r\n + // + // fprintf(fpOut, "// \"%s\\n\"", row); + // } + // + // fprintf(fpOut, "// ;\n"); - char row[1024]; - while (fgets(row, sizeof(row), fpIn)) - { - row[strlen(row) - 1] = 0; // remove \n + fprintf(fpOut, "static const char %s[] =\n{", pVariableName); - fprintf(fpOut, "\"%s\\n\"\n", row); + for (size_t i = 0; i < entireFile.size(); ++i) + { + fprintf(fpOut, "0x%X, ", (uint32_t)entireFile[i]); + if (i % 16 == 15) + { + fprintf(fpOut, "\n"); + } } - - fprintf(fpOut, ";\n"); + fprintf(fpOut, "};\n"); fclose(fpIn); fclose(fpOut); -- cgit v1.2.3