Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
(by purging boost::system)
  • Loading branch information
ashdnazg committed Oct 17, 2016
1 parent d1fd751 commit a619707
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
27 changes: 23 additions & 4 deletions rts/System/FileSystem/Archives/SevenZipArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "SevenZipArchive.h"

#include <algorithm>
#include <boost/system/error_code.hpp>
#include <stdexcept>
#include <string.h> //memcpy

Expand Down Expand Up @@ -86,7 +85,7 @@ IArchive* CSevenZipArchiveFactory::DoCreateArchive(const std::string& filePath)
return new CSevenZipArchive(filePath);
}

const char* CSevenZipArchive::GetErrorStr(int err)
static inline const char* GetErrorStr(int err)
{
switch(err) {
case SZ_OK:
Expand All @@ -108,6 +107,27 @@ const char* CSevenZipArchive::GetErrorStr(int err)
}


static inline std::string GetSystemErrorStr(WRes wres)
{
#ifdef USE_WINDOWS_FILE
LPSTR messageBuffer = nullptr;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, wres, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);

std::string errorstr(messageBuffer, size);

//Free the buffer.
LocalFree(messageBuffer);
#else
return std::string(strerror(wres));
#endif

return errorstr;
}




CSevenZipArchive::CSevenZipArchive(const std::string& name):
CBufferedArchive(name, false),
blockIndex(0xFFFFFFFF),
Expand All @@ -126,9 +146,8 @@ CSevenZipArchive::CSevenZipArchive(const std::string& name):

WRes wres = InFile_Open(&archiveStream.file, name.c_str());
if (wres) {
boost::system::error_code e(wres, boost::system::get_system_category());
LOG_L(L_ERROR, "Error opening \"%s\": %s (%i)",
name.c_str(), e.message().c_str(), e.value());
name.c_str(), GetSystemErrorStr(wres).c_str(), (int) wres);
return;
}

Expand Down
1 change: 0 additions & 1 deletion rts/System/FileSystem/Archives/SevenZipArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class CSevenZipArchive : public CBufferedArchive
int packedSize;
};
int GetFileName(const CSzArEx* db, int i);
const char* GetErrorStr(int res);

std::vector<FileData> fileData;
UInt16 *tempBuf;
Expand Down

0 comments on commit a619707

Please sign in to comment.