1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 14:15:46 +00:00

Initial Haiku support

This commit is contained in:
fgenesis 2012-09-23 05:31:29 +02:00
parent 31930051d5
commit 8ac5cf69ab
2 changed files with 45 additions and 3 deletions

View file

@ -12,6 +12,10 @@ IF(APPLE)
SET(MACOSX TRUE) SET(MACOSX TRUE)
ENDIF(APPLE) ENDIF(APPLE)
IF(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
SET(HAIKU TRUE)
ENDIF()
OPTION(AQUARIA_DEVELOPER_BUILD "Developer Build?" FALSE) OPTION(AQUARIA_DEVELOPER_BUILD "Developer Build?" FALSE)
OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE) OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE)
OPTION(AQUARIA_USE_VFS "Use Virtual File System? Required for some additional features." TRUE) OPTION(AQUARIA_USE_VFS "Use Virtual File System? Required for some additional features." TRUE)
@ -258,9 +262,9 @@ ENDIF(WIN32)
# Build Lua with Unix _setjmp/_longjmp support. # Build Lua with Unix _setjmp/_longjmp support.
IF(UNIX) IF(UNIX AND NOT HAIKU)
ADD_DEFINITIONS(-DLUA_USE_ULONGJMP=1) ADD_DEFINITIONS(-DLUA_USE_ULONGJMP=1)
ENDIF(UNIX) ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC) IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-pipe -fsigned-char) ADD_DEFINITIONS(-pipe -fsigned-char)
@ -627,6 +631,10 @@ IF(MACOSX)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-framework OpenAL") SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-framework OpenAL")
ENDIF(MACOSX) ENDIF(MACOSX)
IF(HAIKU)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "network")
ENDIF()
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${SDL_LIBRARY}) SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${SDL_LIBRARY})
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${OPENAL_LIBRARY}) SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${OPENAL_LIBRARY})

View file

@ -17,7 +17,11 @@
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# include <windows.h> # include <windows.h>
#else #else
# ifdef __HAIKU__
# include <dirent.h>
# else
# include <sys/dir.h> # include <sys/dir.h>
# endif
# include <unistd.h> # include <unistd.h>
#endif #endif
@ -49,6 +53,7 @@ void makeUppercase(std::string& s)
} }
#if !_WIN32 #if !_WIN32
#ifdef DT_DIR
static bool _IsFile(const char *path, dirent *dp) static bool _IsFile(const char *path, dirent *dp)
{ {
switch(dp->d_type) switch(dp->d_type)
@ -93,6 +98,35 @@ static bool _IsDir(const char *path, dirent *dp)
} }
return false; return false;
} }
#else // No DT_DIR, assume plain POSIX
static bool _IsDir(const char *path, dirent *dp)
{
const int len1 = strlen(path);
const int len2 = strlen(dp->d_name);
char *pathname = (char*)alloca(len1 + 1 + len2 + 1 + 13);
strcpy (pathname, path);
/* Avoid UNC-path "//name" on Cygwin. */
if (len1 > 0 && pathname[len1 - 1] != '/')
strcat (pathname, "/");
strcat (pathname, dp->d_name);
struct stat st;
if (stat (pathname, &st))
return false;
return S_ISDIR (st.st_mode);
}
static bool _IsFile(const char *path, dirent *dp)
{
return !_IsDir(path, dp);
}
#endif
#endif #endif
// returns list of *plain* file names in given directory, // returns list of *plain* file names in given directory,