diff options
Diffstat (limited to 'lib/Input.cc')
-rw-r--r-- | lib/Input.cc | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/Input.cc b/lib/Input.cc index fdff787..a6eb09f 100644 --- a/lib/Input.cc +++ b/lib/Input.cc @@ -155,32 +155,24 @@ int Input::wrapopen(const String & fname, openresults_t * results) { printm(M_INFO, _("Wrap-opening ") + fname + "\n"); #endif if (fname[0] != '/') { - bool t; + Archive * t; t = Archive::inarchive(fname); if (t) { #ifdef DEBUG printm(M_BARE, _("Trying to open the file in archive, since it seems to be here\n")); #endif - return Archive::open(fname, results); +#ifdef _WIN32 + hFile = t->GetHandle(); +#endif + return t->open(fname, results); } } results->name = ""; -#if 0 - return open(fname.to_charp(), O_RDONLY -#ifdef _WIN32 - | O_BINARY -#endif - ); +#ifndef _WIN32 + return open(fname.to_charp(), O_RDONLY); #else - HANDLE hFile = CreateFile( - fname.to_charp(), - GENERIC_READ, - 0, - 0, - OPEN_EXISTING, - 0, - 0); - return _open_osfhandle((INT_PTR) hFile, O_RDONLY); + hFile = CreateFile(fname.to_charp(), GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + return _open_osfhandle((INT_PTR) hFile, O_RDONLY | O_BINARY); #endif } @@ -215,14 +207,16 @@ Archive::Archive(Handle * hand, int atype) : create(); } +#ifdef _MSC_VER #pragma pack(1) +#endif struct PEsection_t { char name[8]; Uint32 VSize, VAdd, SizeOf, Pointer, PTRelocs, PTLNs; Uint16 NR, NLN; Uint32 Chars; -}; +} PACKED; void Archive::create() throw (GeneralException) { char buffer[1024]; @@ -305,7 +299,7 @@ Archive::~Archive() { delete archive; } -bool Archive::inarchive(const String & fname) { +Archive * Archive::inarchive(const String & fname) { Archive * p; for (p = header; p; p = p->next) { #ifdef DEBUG @@ -315,13 +309,14 @@ bool Archive::inarchive(const String & fname) { #ifdef DEBUG printm(M_BARE, _("File `") + fname + _("' found in archive ") + p->name + "\n"); #endif - return true; + return p; } } - return false; + return 0; } -int Archive::open(const String & fname, Input::openresults_t * results) throw (GeneralException) { +int Archive::open(const String & fname, Input::openresults_t * results) { +#if 0 Archive * p; for (p = header; p; p = p->next) { @@ -331,6 +326,12 @@ int Archive::open(const String & fname, Input::openresults_t * results) throw (G return p->openin(fname, results); } throw IOGeneral(_("File `") + fname + _("' not found in archive collection.")); +#endif + return openin(fname, results); +} + +Handle * Archive::GetHandle() { + return archive; } bool Archive::inarchivein(const String & fname) { |