From 52bf0ea92942b4a40d7a08e7ac2ee79d3253d48b Mon Sep 17 00:00:00 2001 From: Shawwwn Date: Fri, 16 May 2014 03:51:56 -0700 Subject: [PATCH] Fixed a crash in Release build --- H2OExtractor.dsp | 4 ++++ Source/Archive.cpp | 36 ++++++++++++++++++++---------------- Source/Archive.h | 4 ++++ Source/H2OExtractor.cpp | 7 ++++++- Source/H2OExtractor.h | 4 ---- Source/predefine.h | 8 ++++++++ 6 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 Source/predefine.h diff --git a/H2OExtractor.dsp b/H2OExtractor.dsp index 700e5ac..f8d3ff5 100644 --- a/H2OExtractor.dsp +++ b/H2OExtractor.dsp @@ -175,6 +175,10 @@ SOURCE=.\Source\H2OExtractor.cpp SOURCE=.\Source\H2OExtractor.h # End Source File +# Begin Source File + +SOURCE=.\Source\predefine.h +# End Source File # End Group # Begin Group "Utils" diff --git a/Source/Archive.cpp b/Source/Archive.cpp index 247bf51..63b2cc2 100644 --- a/Source/Archive.cpp +++ b/Source/Archive.cpp @@ -43,7 +43,7 @@ uint64_t Archive::readComment(uint64_t streamPos) memset(m_Comment.szComments, 0, length); m_hH2O.read(m_Comment.szComments, length-1); -#if _DEBUG +#ifdef H2O_DEBUG_LOG DB::debugLog("- ArchiveHeader: ", m_Comment.szHeader, NULL); DB::debugLog("- VersionInfo: ", m_Comment.VersionInfo, NULL); DB::debugLog("- Comments: ", m_Comment.szComments, NULL); @@ -56,7 +56,7 @@ uint64_t Archive::readHeader(uint64_t streamPos) m_hH2O.seekg(streamPos, std::ios::beg); m_hH2O.read((char*)&m_Header, sizeof(ArchiveHeader)); -#if _DEBUG +#ifdef H2O_DEBUG_LOG DB::debugLog("- Version: ", m_Header.Version, NULL); DB::debugLog("- FileCount: ", m_Header.FileCount, NULL); DB::debugLog("- CompressedSize: ", m_Header.CompressedSize, NULL); @@ -75,7 +75,7 @@ uint64_t Archive::readFileList(uint64_t streamPos) if (curFile.RawSize!=0 && curFile.CompressedSize!=0) m_FileList.push_back(curFile); // file is valid - #if defined(_DEBUG) && defined (H2O_PRINT_FILE_DESC) + #if defined(H2O_DEBUG_LOG) && defined (H2O_PRINT_FILE_DESC) DB::debugLog("- CompressionTag: ", curFile.CompressionTag, NULL); DB::debugLog("- FolderNameIndex: ", curFile.FolderNameIndex, NULL); DB::debugLog("- FileNameIndex: ", curFile.FileNameIndex, NULL); @@ -96,7 +96,7 @@ uint64_t Archive::readFileNameDesc(uint64_t streamPos) m_hH2O.seekg(streamPos, std::ios::beg); m_hH2O.read((char*)&m_FileNameDesc, sizeof(ArchiveFileNameDesc)); - #if _DEBUG + #ifdef H2O_DEBUG_LOG DB::debugLog("- CompressedSize: ", m_FileNameDesc.CompressedSize, NULL); DB::debugLog("- RawSize: ", m_FileNameDesc.RawSize, NULL); DB::debugLog("- CRC32[hex]: ", m_FileNameDesc.CRC32, NULL, true); @@ -118,7 +118,7 @@ uint64_t Archive::readDirectoryNameDesc(uint64_t streamPos) m_hH2O.seekg(streamPos, std::ios::beg); m_hH2O.read((char*)&m_DirectoryNameDesc, sizeof(ArchiveDirectoryNameDesc)); - #if _DEBUG + #ifdef H2O_DEBUG_LOG DB::debugLog("- CompressedSize: ", m_DirectoryNameDesc.CompressedSize, NULL); DB::debugLog("- RawSize: ", m_DirectoryNameDesc.RawSize, NULL); DB::debugLog("- CRC32[hex]: ", m_DirectoryNameDesc.CRC32, NULL, true); @@ -142,7 +142,7 @@ uint64_t Archive::readDirectoryParents(uint64_t streamPos) m_arrDirectoryParents = new int32_t[m_DirectoryCount]; m_hH2O.read((char*)m_arrDirectoryParents, sizeof(*m_arrDirectoryParents)*m_DirectoryCount); -#if _DEBUG +#ifdef H2O_DEBUG_LOG DB::debugLog("Directory Count: ", m_DirectoryCount, NULL); #ifdef H2O_PRINT_DIR_INHEIRTANCY for (int i=0; i #include #include #include #include +#include +#include // std::bad_alloc #include "Types.h" #include "./Utils/FileUtils.h" diff --git a/Source/H2OExtractor.cpp b/Source/H2OExtractor.cpp index 69ba9f9..334a632 100644 --- a/Source/H2OExtractor.cpp +++ b/Source/H2OExtractor.cpp @@ -6,8 +6,13 @@ int main(int argc, char* argv[]) printf("H2OExtractor\n============================\n"); Archive h2o("Input.H2O"); + DB::debugLog("\nPress Any Key to Extract Files", "\n", NULL); getchar(); - DB::debugLog("\nExtracting files...", "\n", NULL); + h2o.extractAll(); + + DB::debugLog("\nPress Any Key to Exist", "\n", NULL); + getchar(); + return 0; } \ No newline at end of file diff --git a/Source/H2OExtractor.h b/Source/H2OExtractor.h index b1dfa01..5d71571 100644 --- a/Source/H2OExtractor.h +++ b/Source/H2OExtractor.h @@ -6,8 +6,4 @@ #include -//#define H2O_PRINT_FILE_LIST -//#define H2O_PRINT_FILE_DESC -//#define H2O_PRINT_DIR_INHEIRTANCY - #include "Archive.h" \ No newline at end of file diff --git a/Source/predefine.h b/Source/predefine.h new file mode 100644 index 0000000..fccf61b --- /dev/null +++ b/Source/predefine.h @@ -0,0 +1,8 @@ +/* predefine.h */ +#pragma once + +#define H2O_DEBUG_LOG +#define H2O_PRINT_WHEN_EXTRACT +//#define H2O_PRINT_FILE_LIST +//#define H2O_PRINT_FILE_DESC +//#define H2O_PRINT_DIR_INHEIRTANCY \ No newline at end of file