diff options
-rw-r--r-- | src/FileStream.cpp | 24 | ||||
-rw-r--r-- | src/StormPort.h | 11 | ||||
-rw-r--r-- | test/StormTest.cpp | 6 |
3 files changed, 23 insertions, 18 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp index 45499e1..50f6ea5 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -105,15 +105,15 @@ static bool BaseFile_Create(TFileStream * pStream) }
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
{
intptr_t handle;
handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(handle == -1)
{
- nLastError = errno;
pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
+ nLastError = errno;
return false;
}
@@ -155,7 +155,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD }
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
{
struct stat64 fileinfo;
int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
@@ -165,17 +165,17 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD handle = open(szFileName, oflag | O_LARGEFILE);
if(handle == -1)
{
- nLastError = errno;
pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
+ nLastError = errno;
return false;
}
// Get the file size
if(fstat64(handle, &fileinfo) == -1)
{
+ pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
nLastError = errno;
close(handle);
- pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
return false;
}
@@ -226,7 +226,7 @@ static bool BaseFile_Read( }
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
{
ssize_t bytes_read;
@@ -297,7 +297,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const }
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
{
ssize_t bytes_written;
@@ -364,7 +364,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) }
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
{
if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
{
@@ -408,7 +408,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName);
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
// "rename" on Linux also works if the target file exists
if(rename(pNewStream->szFileName, pStream->szFileName) == -1)
{
@@ -428,7 +428,7 @@ static void BaseFile_Close(TFileStream * pStream) CloseHandle(pStream->Base.File.hFile);
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
close((intptr_t)pStream->Base.File.hFile);
#endif
}
@@ -567,7 +567,7 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStre return false;
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
struct stat64 fileinfo;
intptr_t handle;
bool bResult = false;
@@ -636,7 +636,7 @@ static void BaseMap_Close(TFileStream * pStream) UnmapViewOfFile(pStream->Base.Map.pbFile);
#endif
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
if(pStream->Base.Map.pbFile != NULL)
munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize);
#endif
diff --git a/src/StormPort.h b/src/StormPort.h index aa5a52d..064e514 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -106,6 +106,10 @@ #endif +//----------------------------------------------------------------------------- +// Defines for other platforms. Please, if you add a platform that is compatible +// with either Linux or Mac, define STORMLIB_LINUX or STORMLIB_MAC, respectively + #if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__HAIKU__) #include <sys/types.h> @@ -126,8 +130,9 @@ #define STORMLIB_LITTLE_ENDIAN #endif + #define STORMLIB_MAC // Use Mac compatible code #define STORMLIB_HAIKU - #define STORMLIB_PLATFORM_DEFINED // The platform is known now + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif @@ -228,7 +233,7 @@ #endif // !STORMLIB_WINDOWS // 64-bit calls are supplied by "normal" calls on Mac -#if defined(STORMLIB_MAC) || defined(STORMLIB_HAIKU) +#if defined(STORMLIB_MAC) #define stat64 stat #define fstat64 fstat #define lseek64 lseek @@ -238,7 +243,7 @@ #endif // Platform-specific error codes for UNIX-based platforms -#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU) +#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) #define ERROR_SUCCESS 0 #define ERROR_FILE_NOT_FOUND ENOENT #define ERROR_ACCESS_DENIED EPERM diff --git a/test/StormTest.cpp b/test/StormTest.cpp index 83be4e2..0993826 100644 --- a/test/StormTest.cpp +++ b/test/StormTest.cpp @@ -688,7 +688,7 @@ static HANDLE InitDirectorySearch(LPCTSTR szDirectory) #endif
-#if defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_LINUX) || defined(STORMLIB_MAC)
// Keep compilers happy
return (HANDLE)opendir(szDirectory);
@@ -723,7 +723,7 @@ static bool SearchDirectory(HANDLE hFind, TCHAR * szDirEntry, size_t cchDirEntry #endif
-#if defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_LINUX) || defined(STORMLIB_MAC)
struct dirent * directory_entry;
@@ -746,7 +746,7 @@ static void FreeDirectorySearch(HANDLE hFind) FindClose(hFind);
#endif
-#if defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
+#if defined(STORMLIB_LINUX) || defined(STORMLIB_MAC)
closedir((DIR *)hFind);
#endif
}
|