From d8611e18ae3c013290821548557e02f5222e6f66 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 28 Dec 2018 11:39:39 -0700 Subject: [PATCH] platform dependent "sysEOF" const added --- formats/mpq/mpq.go | 7 ++++--- formats/mpq/mpq_linux.go | 7 +++++++ formats/mpq/mpq_windows.go | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 formats/mpq/mpq_linux.go create mode 100644 formats/mpq/mpq_windows.go diff --git a/formats/mpq/mpq.go b/formats/mpq/mpq.go index bdc30e4..5274e31 100644 --- a/formats/mpq/mpq.go +++ b/formats/mpq/mpq.go @@ -9,13 +9,14 @@ package mpq // #define WINAPI // DWORD GetLastError(); // #endif +// // #define DWORD unsigned int -// #define HANDLE void * -// #define LONG int // #define LPDWORD unsigned int * // #define LPOVERLAPPED void * // #define TCHAR char +// #define HANDLE void * // #define bool unsigned char +// #define LONG int // // bool WINAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq); // bool WINAPI SFileCloseArchive(HANDLE hMpq); @@ -72,7 +73,7 @@ func (f *file) Read(data []byte) (int, error) { var bytesRead int if result := C.SFileReadFile(f.handle, unsafe.Pointer(&data[0]), C.uint(len(data)), (*C.uint)(unsafe.Pointer(&bytesRead)), nil); result == 0 { lastError := getLastError() - if lastError == 1002 || lastError == 38 { // ERROR_HANDLE_EOF + if lastError == sysEOF { // ERROR_HANDLE_EOF return bytesRead, io.EOF } diff --git a/formats/mpq/mpq_linux.go b/formats/mpq/mpq_linux.go new file mode 100644 index 0000000..60edd0b --- /dev/null +++ b/formats/mpq/mpq_linux.go @@ -0,0 +1,7 @@ +// +build linux + +package mpq + +const ( + sysEOF = 1002 +) diff --git a/formats/mpq/mpq_windows.go b/formats/mpq/mpq_windows.go new file mode 100644 index 0000000..0e3cdba --- /dev/null +++ b/formats/mpq/mpq_windows.go @@ -0,0 +1,7 @@ +// +build windows + +package mpq + +const ( + sysEOF = 38 +)