From 738444bddcf49c09744519a44920dde9d1f29359 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 24 Oct 2020 09:21:20 +0200 Subject: Changed PLATFORM_* to STORMLIB_* --- src/FileStream.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/FileStream.cpp') 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; -- cgit v1.2.3