diff --git a/CMakeLists.txt b/CMakeLists.txt index aba0839..bac44f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ IF(APPLE) SET(MACOSX TRUE) ENDIF(APPLE) +IF(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + SET(HAIKU TRUE) +ENDIF() + OPTION(AQUARIA_DEVELOPER_BUILD "Developer Build?" FALSE) OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE) 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. -IF(UNIX) +IF(UNIX AND NOT HAIKU) ADD_DEFINITIONS(-DLUA_USE_ULONGJMP=1) -ENDIF(UNIX) +ENDIF() IF(CMAKE_COMPILER_IS_GNUCC) ADD_DEFINITIONS(-pipe -fsigned-char) @@ -627,6 +631,10 @@ IF(MACOSX) SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-framework OpenAL") ENDIF(MACOSX) +IF(HAIKU) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "network") +ENDIF() + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${SDL_LIBRARY}) SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${OPENAL_LIBRARY}) diff --git a/ExternalLibs/ttvfs/VFSTools.cpp b/ExternalLibs/ttvfs/VFSTools.cpp index 5bb5e03..6a34e28 100644 --- a/ExternalLibs/ttvfs/VFSTools.cpp +++ b/ExternalLibs/ttvfs/VFSTools.cpp @@ -17,8 +17,12 @@ # define WIN32_LEAN_AND_MEAN # include #else +# ifdef __HAIKU__ +# include +# else # include -# include +# endif +# include #endif #include @@ -49,6 +53,7 @@ void makeUppercase(std::string& s) } #if !_WIN32 +#ifdef DT_DIR static bool _IsFile(const char *path, dirent *dp) { switch(dp->d_type) @@ -93,6 +98,35 @@ static bool _IsDir(const char *path, dirent *dp) } 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 // returns list of *plain* file names in given directory,