From fc98559fb67baa9f9d42ffe93bb6713c0a272d05 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 28 Dec 2017 19:47:49 -0800 Subject: Reworked File2Include to use standard io functions --- Utilities/File2Include/.gitignore | 2 - Utilities/File2Include/CMakeLists.txt | 1 + Utilities/File2Include/File2String.cpp | 43 +++++---- Utilities/File2Include/File2String.sln | 22 ----- Utilities/File2Include/File2String.vcxproj | 98 --------------------- Utilities/File2Include/File2String.vcxproj.filters | 36 -------- Utilities/File2Include/ReadMe.txt | 40 --------- .../File2Include/bin/Win32/x32/File2String.exe | Bin 109056 -> 109568 bytes .../File2Include/bin/Win32/x64/File2String.exe | Bin 127488 -> 127488 bytes Utilities/File2Include/stdafx.cpp | 8 -- Utilities/File2Include/stdafx.h | 15 ---- Utilities/File2Include/targetver.h | 8 -- 12 files changed, 25 insertions(+), 248 deletions(-) delete mode 100644 Utilities/File2Include/.gitignore delete mode 100644 Utilities/File2Include/File2String.sln delete mode 100644 Utilities/File2Include/File2String.vcxproj delete mode 100644 Utilities/File2Include/File2String.vcxproj.filters delete mode 100644 Utilities/File2Include/ReadMe.txt delete mode 100644 Utilities/File2Include/stdafx.cpp delete mode 100644 Utilities/File2Include/stdafx.h delete mode 100644 Utilities/File2Include/targetver.h (limited to 'Utilities/File2Include') diff --git a/Utilities/File2Include/.gitignore b/Utilities/File2Include/.gitignore deleted file mode 100644 index f8db2d27..00000000 --- a/Utilities/File2Include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -**/debug -**/release diff --git a/Utilities/File2Include/CMakeLists.txt b/Utilities/File2Include/CMakeLists.txt index 363bfad6..bedead45 100644 --- a/Utilities/File2Include/CMakeLists.txt +++ b/Utilities/File2Include/CMakeLists.txt @@ -13,6 +13,7 @@ if(PLATFORM_WIN32) if(MSVC) set(MSVC_DBG_COMPILE_OPTIONS /MTd) set(MSVC_REL_COMPILE_OPTIONS /MT) + target_compile_options(File2String PRIVATE /wd4996) target_compile_options(File2String PRIVATE "$<$:${MSVC_DBG_COMPILE_OPTIONS}>") target_compile_options(File2String PRIVATE "$<$:${MSVC_REL_COMPILE_OPTIONS}>") target_compile_options(File2String PRIVATE "$<$:${MSVC_REL_COMPILE_OPTIONS}>") diff --git a/Utilities/File2Include/File2String.cpp b/Utilities/File2Include/File2String.cpp index 9b416da7..eca6c01f 100644 --- a/Utilities/File2Include/File2String.cpp +++ b/Utilities/File2Include/File2String.cpp @@ -1,11 +1,10 @@ // File2Include.cpp : Defines the entry point for the console application. // -#include "stdafx.h" -#include "stdio.h" -#include "tchar.h" +#include +#include -int _tmain(int argc, _TCHAR* argv[]) +int main(int argc, char* argv[]) { if( argc < 3 ) { @@ -14,45 +13,51 @@ int _tmain(int argc, _TCHAR* argv[]) } auto SrcFile = argv[1]; auto DstFile = argv[2]; - FILE *pSrcFile = nullptr; - if( _tfopen_s( &pSrcFile, SrcFile, _T( "r" ) ) != 0 ) + if (strcmp(SrcFile, DstFile) == 0) { - _tprintf( _T("Failed to open source file %s\n"), SrcFile ); + printf( "Source and destination files must be different\n"); return -1; } - FILE *pDstFile = nullptr; - if( _tfopen_s(&pDstFile, DstFile, _T( "w" ) ) != 0 ) + FILE *pSrcFile = fopen( SrcFile, "r" ); + if( pSrcFile == nullptr ) { - _tprintf( _T("Failed to open destination file %s\n"), DstFile ); + printf( "Failed to open source file %s\n", SrcFile ); + return -1; + } + + FILE *pDstFile = fopen( DstFile, "w" ); + if( pDstFile == nullptr ) + { + printf( "Failed to open destination file %s\n", DstFile ); fclose(pSrcFile); return -1; } - _TCHAR Buff[1024]; - _TCHAR SpecialChars[] = _T( "\'\"\\" ); + char Buff[2048]; + char SpecialChars[] = "\'\"\\"; while( !feof( pSrcFile ) ) { - auto Line = _fgetts( Buff, sizeof( Buff )/sizeof(Buff[0]) , pSrcFile ); + auto Line = fgets( Buff, sizeof( Buff )/sizeof(Buff[0]) , pSrcFile ); if( Line == nullptr ) break; - _fputtc( _T( '\"' ), pDstFile ); + fputc( '\"', pDstFile ); auto CurrChar = Line; while( CurrChar && *CurrChar != '\n' ) { - if( _tcschr( SpecialChars, *CurrChar) ) - _fputtc( _T( '\\' ), pDstFile ); - _fputtc( *CurrChar, pDstFile ); + if( strchr( SpecialChars, *CurrChar) ) + fputc( '\\', pDstFile ); + fputc( *CurrChar, pDstFile ); ++CurrChar; } - _fputts( _T("\\n\"\n"), pDstFile ); + fputs( "\\n\"\n", pDstFile ); } fclose(pDstFile); fclose(pSrcFile); - _tprintf( _T("File2String: sucessfully converted %s to %s\n"), SrcFile, DstFile ); + printf( "File2String: sucessfully converted %s to %s\n", SrcFile, DstFile ); return 0; } diff --git a/Utilities/File2Include/File2String.sln b/Utilities/File2Include/File2String.sln deleted file mode 100644 index 50b94f3a..00000000 --- a/Utilities/File2Include/File2String.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "File2String", "File2String.vcxproj", "{D1DEE902-0993-4FDF-8A4D-03705BC040A2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D1DEE902-0993-4FDF-8A4D-03705BC040A2}.Debug|Win32.ActiveCfg = Debug|Win32 - {D1DEE902-0993-4FDF-8A4D-03705BC040A2}.Debug|Win32.Build.0 = Debug|Win32 - {D1DEE902-0993-4FDF-8A4D-03705BC040A2}.Release|Win32.ActiveCfg = Release|Win32 - {D1DEE902-0993-4FDF-8A4D-03705BC040A2}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Utilities/File2Include/File2String.vcxproj b/Utilities/File2Include/File2String.vcxproj deleted file mode 100644 index e73e3e72..00000000 --- a/Utilities/File2Include/File2String.vcxproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D1DEE902-0993-4FDF-8A4D-03705BC040A2} - Win32Proj - File2Include - File2String - - - - Application - true - v140 - Unicode - - - Application - false - v140 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - - - Console - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - - - - - - - - - - - - - Create - Create - - - - - - \ No newline at end of file diff --git a/Utilities/File2Include/File2String.vcxproj.filters b/Utilities/File2Include/File2String.vcxproj.filters deleted file mode 100644 index fa46de9d..00000000 --- a/Utilities/File2Include/File2String.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/Utilities/File2Include/ReadMe.txt b/Utilities/File2Include/ReadMe.txt deleted file mode 100644 index 8f5b8397..00000000 --- a/Utilities/File2Include/ReadMe.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : File2Include Project Overview -======================================================================== - -AppWizard has created this File2Include application for you. - -This file contains a summary of what you will find in each of the files that -make up your File2Include application. - - -File2Include.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -File2Include.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -File2Include.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named File2Include.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/Utilities/File2Include/bin/Win32/x32/File2String.exe b/Utilities/File2Include/bin/Win32/x32/File2String.exe index d43a71cf..cca8f392 100644 Binary files a/Utilities/File2Include/bin/Win32/x32/File2String.exe and b/Utilities/File2Include/bin/Win32/x32/File2String.exe differ diff --git a/Utilities/File2Include/bin/Win32/x64/File2String.exe b/Utilities/File2Include/bin/Win32/x64/File2String.exe index 13f223da..1ac29ab1 100644 Binary files a/Utilities/File2Include/bin/Win32/x64/File2String.exe and b/Utilities/File2Include/bin/Win32/x64/File2String.exe differ diff --git a/Utilities/File2Include/stdafx.cpp b/Utilities/File2Include/stdafx.cpp deleted file mode 100644 index d7e78357..00000000 --- a/Utilities/File2Include/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// File2Include.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/Utilities/File2Include/stdafx.h b/Utilities/File2Include/stdafx.h deleted file mode 100644 index b005a839..00000000 --- a/Utilities/File2Include/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/Utilities/File2Include/targetver.h b/Utilities/File2Include/targetver.h deleted file mode 100644 index 87c0086d..00000000 --- a/Utilities/File2Include/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include -- cgit v1.2.3