diff options
-rw-r--r-- | src/FileStream.cpp | 46 | ||||
-rw-r--r-- | src/SBaseCommon.cpp | 4 | ||||
-rw-r--r-- | src/SBaseFileTable.cpp | 10 | ||||
-rw-r--r-- | src/StormLib.h | 4 | ||||
-rw-r--r-- | src/StormPort.h | 52 |
5 files changed, 58 insertions, 58 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp index a462690..06f7627 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -33,7 +33,7 @@ //-----------------------------------------------------------------------------
// Local functions - platform-specific functions
-#ifndef PLATFORM_WINDOWS
+#ifndef STORMLIB_WINDOWS
static DWORD nLastError = ERROR_SUCCESS;
DWORD GetLastError()
@@ -89,7 +89,7 @@ static void BaseNone_Init(TFileStream *) static bool BaseFile_Create(TFileStream * pStream)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
{
DWORD dwWriteShare = (pStream->dwFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0;
@@ -105,7 +105,7 @@ static bool BaseFile_Create(TFileStream * pStream) }
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
intptr_t handle;
@@ -128,7 +128,7 @@ static bool BaseFile_Create(TFileStream * pStream) static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
{
ULARGE_INTEGER FileSize;
DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES;
@@ -154,7 +154,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD }
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
struct stat64 fileinfo;
int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
@@ -199,7 +199,7 @@ static bool BaseFile_Read( ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.File.FilePos;
DWORD dwBytesRead = 0; // Must be set by platform-specific code
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
{
// Note: StormLib no longer supports Windows 9x.
// Thus, we can use the OVERLAPPED structure to specify
@@ -223,7 +223,7 @@ static bool BaseFile_Read( }
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
ssize_t bytes_read;
@@ -270,7 +270,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.File.FilePos;
DWORD dwBytesWritten = 0; // Must be set by platform-specific code
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
{
// Note: StormLib no longer supports Windows 9x.
// Thus, we can use the OVERLAPPED structure to specify
@@ -294,7 +294,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const }
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
ssize_t bytes_written;
@@ -336,7 +336,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const */
static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
{
LONG FileSizeHi = (LONG)(NewFileSize >> 32);
LONG FileSizeLo;
@@ -361,7 +361,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) }
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
{
@@ -396,7 +396,7 @@ static bool BaseFile_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) // Renames the file pointed by pStream so that it contains data from pNewStream
static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
// Delete the original stream file. Don't check the result value,
// because if the file doesn't exist, it would fail
DeleteFile(pStream->szFileName);
@@ -405,7 +405,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
// "rename" on Linux also works if the target file exists
if(rename(pNewStream->szFileName, pStream->szFileName) == -1)
{
@@ -421,11 +421,11 @@ static void BaseFile_Close(TFileStream * pStream) {
if(pStream->Base.File.hFile != INVALID_HANDLE_VALUE)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
CloseHandle(pStream->Base.File.hFile);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
close((intptr_t)pStream->Base.File.hFile);
#endif
}
@@ -450,7 +450,7 @@ static void BaseFile_Init(TFileStream * pStream) //-----------------------------------------------------------------------------
// Local functions - base memory-mapped file support
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
typedef struct _SECTION_BASIC_INFORMATION
{
@@ -493,7 +493,7 @@ static bool RetrieveFileMappingSize(HANDLE hSection, ULARGE_INTEGER & RefFileSiz static bool BaseMap_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStreamFlags)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
ULARGE_INTEGER FileSize = {0};
HANDLE hFile = INVALID_HANDLE_VALUE;
@@ -564,7 +564,7 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStre return false;
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
struct stat64 fileinfo;
intptr_t handle;
bool bResult = false;
@@ -628,12 +628,12 @@ static bool BaseMap_Read( static void BaseMap_Close(TFileStream * pStream)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
if(pStream->Base.Map.pbFile != NULL)
UnmapViewOfFile(pStream->Base.Map.pbFile);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
if(pStream->Base.Map.pbFile != NULL)
munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize);
#endif
@@ -683,7 +683,7 @@ static const TCHAR * BaseHttp_ExtractServerName(const TCHAR * szFileName, TCHAR static bool BaseHttp_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
HINTERNET hRequest;
DWORD dwTemp = 0;
@@ -795,7 +795,7 @@ static bool BaseHttp_Read( void * pvBuffer, // Pointer to data to be read
DWORD dwBytesToRead) // Number of bytes to read from the file
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.Http.FilePos;
DWORD dwTotalBytesRead = 0;
@@ -868,7 +868,7 @@ static bool BaseHttp_Read( static void BaseHttp_Close(TFileStream * pStream)
{
-#ifdef PLATFORM_WINDOWS
+#ifdef STORMLIB_WINDOWS
if(pStream->Base.Http.hConnect != NULL)
InternetCloseHandle(pStream->Base.Http.hConnect);
pStream->Base.Http.hConnect = NULL;
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp index a116625..34a7a25 100644 --- a/src/SBaseCommon.cpp +++ b/src/SBaseCommon.cpp @@ -1738,7 +1738,7 @@ void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_ha //-----------------------------------------------------------------------------
// Swapping functions
-#ifndef PLATFORM_LITTLE_ENDIAN
+#ifndef STORMLIB_LITTLE_ENDIAN
//
// Note that those functions are implemented for Mac operating system,
@@ -1863,4 +1863,4 @@ void ConvertTMPQHeader(void *header, uint16_t version) }
}
-#endif // PLATFORM_LITTLE_ENDIAN
+#endif // STORMLIB_LITTLE_ENDIAN
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp index 6bcf782..e94e61f 100644 --- a/src/SBaseFileTable.cpp +++ b/src/SBaseFileTable.cpp @@ -57,7 +57,7 @@ static DWORD GetNecessaryBitCount(ULONGLONG MaxValue) }
//-----------------------------------------------------------------------------
-// Support functions for TBitArray
+// Implementation of the TBitArray struc
struct TBitArray
{
@@ -112,7 +112,7 @@ void TBitArray::GetBits( assert(pbBuffer[i] == 0);
#endif
-#ifndef PLATFORM_LITTLE_ENDIAN
+#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
#endif
@@ -130,7 +130,7 @@ void TBitArray::GetBits( BitBuffer = Elements[nBytePosition0];
}
-#ifdef PLATFORM_LITTLE_ENDIAN
+#ifdef STORMLIB_LITTLE_ENDIAN
*pbBuffer++ = BitBuffer;
#else
*pbBuffer-- = BitBuffer;
@@ -171,7 +171,7 @@ void TBitArray::SetBits( // Keep compiler happy for platforms where nResultByteSize is not used
nResultByteSize = nResultByteSize;
-#ifndef PLATFORM_LITTLE_ENDIAN
+#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
#endif
@@ -180,7 +180,7 @@ void TBitArray::SetBits( while(nBitLength > 8)
{
// Reload the bit buffer
-#ifdef PLATFORM_LITTLE_ENDIAN
+#ifdef STORMLIB_LITTLE_ENDIAN
OneByte = *pbBuffer++;
#else
OneByte = *pbBuffer--;
diff --git a/src/StormLib.h b/src/StormLib.h index 62a8f37..4ddfee3 100644 --- a/src/StormLib.h +++ b/src/StormLib.h @@ -618,7 +618,7 @@ typedef struct _TMPQHash // The hash of the file path, using method B. DWORD dwName2; -#ifdef PLATFORM_LITTLE_ENDIAN +#ifdef STORMLIB_LITTLE_ENDIAN // The language of the file. This is a Windows LANGID data type, and uses the same values. // 0 indicates the default language (American English), or that the file is language-neutral. @@ -1092,7 +1092,7 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pv //----------------------------------------------------------------------------- // Non-Windows support for SetLastError/GetLastError -#ifndef PLATFORM_WINDOWS +#ifndef STORMLIB_WINDOWS void SetLastError(DWORD dwErrCode); DWORD GetLastError(); diff --git a/src/StormPort.h b/src/StormPort.h index 7a1bdb2..6773975 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -36,7 +36,7 @@ //----------------------------------------------------------------------------- // Defines for Windows -#if !defined(PLATFORM_DEFINED) && defined(_WIN32) +#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(_WIN32) // In MSVC 8.0, there are some functions declared as deprecated. #if _MSC_VER >= 1400 @@ -54,25 +54,25 @@ #include <windows.h> #include <wininet.h> - #define PLATFORM_LITTLE_ENDIAN + #define STORMLIB_LITTLE_ENDIAN #ifdef _WIN64 - #define PLATFORM_64BIT + #define STORMLIB_64BIT #else - #define PLATFORM_32BIT + #define STORMLIB_32BIT #endif #define STORMLIB_CDECL __cdecl - #define PLATFORM_WINDOWS - #define PLATFORM_DEFINED // The platform is known now + #define STORMLIB_WINDOWS + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif //----------------------------------------------------------------------------- // Defines for Mac -#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API +#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API // Macintosh #include <sys/types.h> @@ -94,15 +94,15 @@ #define __SYS_BZLIB #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN + #define STORMLIB_LITTLE_ENDIAN #endif - #define PLATFORM_MAC - #define PLATFORM_DEFINED // The platform is known now + #define STORMLIB_MAC + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif -#if !defined(PLATFORM_DEFINED) && defined(__HAIKU__) +#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__HAIKU__) #include <sys/types.h> #include <sys/stat.h> @@ -119,18 +119,18 @@ #include <errno.h> #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN + #define STORMLIB_LITTLE_ENDIAN #endif - #define PLATFORM_HAIKU - #define PLATFORM_DEFINED // The platform is known now + #define STORMLIB_HAIKU + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif //----------------------------------------------------------------------------- // Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* -#if !defined(PLATFORM_DEFINED) +#if !defined(STORMLIB_PLATFORM_DEFINED) #include <sys/types.h> #include <sys/stat.h> @@ -147,20 +147,20 @@ #include <assert.h> #include <errno.h> - #define PLATFORM_LITTLE_ENDIAN - #define PLATFORM_LINUX - #define PLATFORM_DEFINED + #define STORMLIB_LITTLE_ENDIAN + #define STORMLIB_LINUX + #define STORMLIB_PLATFORM_DEFINED #endif //----------------------------------------------------------------------------- // Definition of Windows-specific types for non-Windows platforms -#ifndef PLATFORM_WINDOWS +#ifndef STORMLIB_WINDOWS #if __LP64__ - #define PLATFORM_64BIT + #define STORMLIB_64BIT #else - #define PLATFORM_32BIT + #define STORMLIB_32BIT #endif // __cdecl meand nothing on non-Windows @@ -188,7 +188,7 @@ typedef char * LPTSTR; typedef char * LPSTR; - #ifdef PLATFORM_32BIT + #ifdef STORMLIB_32BIT #define _LZMA_UINT32_IS_ULONG #endif @@ -225,10 +225,10 @@ #define _tcsicmp strcasecmp #define _tcsnicmp strncasecmp -#endif // !PLATFORM_WINDOWS +#endif // !STORMLIB_WINDOWS // 64-bit calls are supplied by "normal" calls on Mac -#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) +#if defined(STORMLIB_MAC) || defined(STORMLIB_HAIKU) #define stat64 stat #define fstat64 fstat #define lseek64 lseek @@ -238,7 +238,7 @@ #endif // Platform-specific error codes for UNIX-based platforms -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) +#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU) #define ERROR_SUCCESS 0 #define ERROR_FILE_NOT_FOUND ENOENT #define ERROR_ACCESS_DENIED EPERM @@ -260,7 +260,7 @@ //----------------------------------------------------------------------------- // Swapping functions -#ifdef PLATFORM_LITTLE_ENDIAN +#ifdef STORMLIB_LITTLE_ENDIAN #define BSWAP_INT16_UNSIGNED(a) (a) #define BSWAP_INT16_SIGNED(a) (a) #define BSWAP_INT32_UNSIGNED(a) (a) |