Skip to content

Commit b4e74f6

Browse files
Merge pull request ladislav-zezula#158 from extrowerk/haiku_support_pt2
FileStream.cpp: Add Haiku platform support
2 parents f12d9db + 149b4ec commit b4e74f6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/FileStream.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static bool BaseFile_Create(TFileStream * pStream)
8989
}
9090
#endif
9191

92-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
92+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
9393
{
9494
intptr_t handle;
9595

@@ -138,7 +138,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD
138138
}
139139
#endif
140140

141-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
141+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
142142
{
143143
struct stat64 fileinfo;
144144
int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
@@ -207,7 +207,7 @@ static bool BaseFile_Read(
207207
}
208208
#endif
209209

210-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
210+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
211211
{
212212
ssize_t bytes_read;
213213

@@ -278,7 +278,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const
278278
}
279279
#endif
280280

281-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
281+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
282282
{
283283
ssize_t bytes_written;
284284

@@ -345,7 +345,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize)
345345
}
346346
#endif
347347

348-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
348+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
349349
{
350350
if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
351351
{
@@ -389,7 +389,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream)
389389
return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName);
390390
#endif
391391

392-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
392+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
393393
// "rename" on Linux also works if the target file exists
394394
if(rename(pNewStream->szFileName, pStream->szFileName) == -1)
395395
{
@@ -409,7 +409,7 @@ static void BaseFile_Close(TFileStream * pStream)
409409
CloseHandle(pStream->Base.File.hFile);
410410
#endif
411411

412-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
412+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
413413
close((intptr_t)pStream->Base.File.hFile);
414414
#endif
415415
}
@@ -488,7 +488,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD
488488
return false;
489489
#endif
490490

491-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
491+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
492492
struct stat64 fileinfo;
493493
intptr_t handle;
494494
bool bResult = false;
@@ -557,7 +557,7 @@ static void BaseMap_Close(TFileStream * pStream)
557557
UnmapViewOfFile(pStream->Base.Map.pbFile);
558558
#endif
559559

560-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
560+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
561561
if(pStream->Base.Map.pbFile != NULL)
562562
munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize);
563563
#endif

test/StormTest.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ static HANDLE InitDirectorySearch(LPCTSTR szDirectory)
718718

719719
#endif
720720

721-
#ifdef PLATFORM_LINUX
721+
#if defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
722722

723723
// Keep compilers happy
724724
return (HANDLE)opendir(szDirectory);
@@ -753,7 +753,7 @@ static bool SearchDirectory(HANDLE hFind, TCHAR * szDirEntry, size_t cchDirEntry
753753

754754
#endif
755755

756-
#ifdef PLATFORM_LINUX
756+
#if defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
757757

758758
struct dirent * directory_entry;
759759

@@ -776,7 +776,7 @@ static void FreeDirectorySearch(HANDLE hFind)
776776
FindClose(hFind);
777777
#endif
778778

779-
#ifdef PLATFORM_LINUX
779+
#if defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
780780
closedir((DIR *)hFind);
781781
#endif
782782
}

0 commit comments

Comments
 (0)