aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FileStream.cpp18
-rw-r--r--src/StormPort.h37
2 files changed, 40 insertions, 15 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp
index 514a683..43a5f4f 100644
--- a/src/FileStream.cpp
+++ b/src/FileStream.cpp
@@ -89,7 +89,7 @@ static bool BaseFile_Create(TFileStream * pStream)
}
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
{
intptr_t handle;
@@ -138,7 +138,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD
}
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
{
struct stat64 fileinfo;
int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
@@ -207,7 +207,7 @@ static bool BaseFile_Read(
}
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
{
ssize_t bytes_read;
@@ -278,7 +278,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const
}
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
{
ssize_t bytes_written;
@@ -345,7 +345,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize)
}
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
{
if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
{
@@ -389,7 +389,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream)
return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
// "rename" on Linux also works if the target file exists
if(rename(pNewStream->szFileName, pStream->szFileName) == -1)
{
@@ -409,7 +409,7 @@ static void BaseFile_Close(TFileStream * pStream)
CloseHandle(pStream->Base.File.hFile);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
close((intptr_t)pStream->Base.File.hFile);
#endif
}
@@ -488,7 +488,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD
return false;
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
struct stat64 fileinfo;
intptr_t handle;
bool bResult = false;
@@ -557,7 +557,7 @@ static void BaseMap_Close(TFileStream * pStream)
UnmapViewOfFile(pStream->Base.Map.pbFile);
#endif
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
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 1da974b..c842a8a 100644
--- a/src/StormPort.h
+++ b/src/StormPort.h
@@ -81,7 +81,7 @@
#if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1)
#include <stdint.h>
#include <CoreFoundation/CFByteOrder.h>
- #endif
+ #endif
#define PKEXPORT
#define __SYS_ZLIB
@@ -96,6 +96,31 @@
#endif
+#if !defined(PLATFORM_DEFINED) && defined(__HAIKU__)
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/mman.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include <assert.h>
+ #include <errno.h>
+
+ #ifndef __BIG_ENDIAN__
+ #define PLATFORM_LITTLE_ENDIAN
+ #endif
+
+ #define PLATFORM_HAIKU
+ #define PLATFORM_DEFINED // The platform is known now
+
+#endif
+
//-----------------------------------------------------------------------------
// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin*
@@ -165,8 +190,8 @@
#ifndef _countof
#define _countof(x) (sizeof(x) / sizeof(x[0]))
#endif
-
- #define WINAPI
+
+ #define WINAPI
#define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR
@@ -193,7 +218,7 @@
#endif // !PLATFORM_WINDOWS
// 64-bit calls are supplied by "normal" calls on Mac
-#if defined(PLATFORM_MAC)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU)
#define stat64 stat
#define fstat64 fstat
#define lseek64 lseek
@@ -201,9 +226,9 @@
#define off64_t off_t
#define O_LARGEFILE 0
#endif
-
+
// Platform-specific error codes for UNIX-based platforms
-#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
#define ERROR_SUCCESS 0
#define ERROR_FILE_NOT_FOUND ENOENT
#define ERROR_ACCESS_DENIED EPERM