Hello! I'm currently updating MPQLib for MoP. I got it working with the newest MPQ files excepted the files which have the flag "Incremental Patch".
Here is the part which fails:
Code:
System::Void MpqLib::Mpq::CFileStream::Open()
{
System::Int32 BytesRead = 0;
pin_ptr<HANDLE> HandlePointer = &_Handle;
CStringHandle FileNameHandle(_FileName);
if(_Archive == nullptr) throw gcnew System::InvalidOperationException("The file stream has no associated archive!");
if(_Archive->IsDisposed) throw gcnew System::ObjectDisposedException(nullptr, "The archive of the file stream has been disposed!");
if((_Archive->Handle == NULL) || (_Archive->Handle == INVALID_HANDLE_VALUE)) throw gcnew System::InvalidOperationException("The archive of the file stream has been closed!");
if(!_Archive->FileExists(_FileName)) throw gcnew System::IO::FileNotFoundException("Could not find \"" + _FileName + "\"!", _FileName);
if(!SFileOpenFileEx(_Archive->Handle, FileNameHandle.Value, 1, HandlePointer) && !SFileOpenFileEx(_Archive->Handle, FileNameHandle.Value, 0, HandlePointer)) throw gcnew System::IO::IOException("Unable to open \"" + _FileName + "\"!");
DWORD length;
SFileGetFileInfo(_Handle, SFILE_INFO_FILE_SIZE, &length, 4, NULL);
_Length = length;
if(_Length < 0) _Length = 0;
_Cache->resize(static_cast<System::UInt32>(_Length));
if(!SFileReadFile(_Handle, &((*_Cache)[0]), static_cast<DWORD>(_Length), reinterpret_cast<LPDWORD>(&BytesRead), NULL)) throw gcnew System::IO::IOException("Read operation failed with error: " + GetLastError());
if(_Length != static_cast<System::Int64>(BytesRead)) throw gcnew System::IO::IOException("Read failed, expected " + _Length + " bytes, read " + BytesRead + " bytes!");
_Position = 0;
}
At the end it fails with error code 38 which is end of file..
Do you got an idea what could be wrong with it?
*Found Solution o.O* Please close thx!