mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Untested Haiku port?
This commit is contained in:
parent
17585c4602
commit
6a0ee21082
4 changed files with 198 additions and 5 deletions
|
@ -111,6 +111,7 @@ SET(PFS_SRC
|
|||
../third_party/physfs/physfs_platform_posix.c
|
||||
../third_party/physfs/physfs_platform_unix.c
|
||||
../third_party/physfs/physfs_platform_windows.c
|
||||
../third_party/physfs/physfs_platform_haiku.cpp
|
||||
)
|
||||
IF(APPLE)
|
||||
# Are you noticing a pattern with this Apple crap yet?
|
||||
|
@ -171,3 +172,9 @@ IF(APPLE)
|
|||
FIND_LIBRARY(IOKIT NAMES IOKit)
|
||||
TARGET_LINK_LIBRARIES(VVVVVV objc ${IOKIT} ${FOUNDATION})
|
||||
ENDIF()
|
||||
# But hey, also some Haiku crap
|
||||
IF(HAIKU)
|
||||
FIND_LIBRARY(BE_LIBRARY be)
|
||||
FIND_LIBRARY(ROOT_LIBRARY root)
|
||||
TARGET_LINK_LIBRARIES(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
|
||||
ENDIF()
|
||||
|
|
|
@ -22,7 +22,7 @@ int mkdir(char* path, int mode)
|
|||
return CreateDirectoryW(utf16_path, NULL);
|
||||
}
|
||||
#define VNEEDS_MIGRATION (mkdirResult != 0)
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
#define VNEEDS_MIGRATION (mkdirResult == 0)
|
||||
|
@ -209,7 +209,7 @@ void PLATFORM_migrateSaveData(char* output)
|
|||
char oldLocation[MAX_PATH];
|
||||
char newLocation[MAX_PATH];
|
||||
char oldDirectory[MAX_PATH];
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
DIR *dir = NULL;
|
||||
struct dirent *de = NULL;
|
||||
DIR *subDir = NULL;
|
||||
|
@ -222,7 +222,7 @@ void PLATFORM_migrateSaveData(char* output)
|
|||
return;
|
||||
}
|
||||
strcpy(oldDirectory, homeDir);
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
strcat(oldDirectory, "/.vvvvvv/");
|
||||
#elif defined(__APPLE__)
|
||||
strcat(oldDirectory, "/Documents/VVVVVV/");
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define STEAM_LIBRARY "steam_api.dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define STEAM_LIBRARY "libsteam_api.dylib"
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
#define STEAM_LIBRARY "libsteam_api.so"
|
||||
#else
|
||||
#error STEAM_LIBRARY: Unrecognized platform!
|
||||
|
@ -95,7 +95,7 @@ static void ClearPointers()
|
|||
|
||||
int32_t STEAM_init()
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
|
||||
return 0;
|
||||
#endif
|
||||
intptr_t steamClient;
|
||||
|
|
186
third_party/physfs/physfs_platform_haiku.cpp
vendored
Normal file
186
third_party/physfs/physfs_platform_haiku.cpp
vendored
Normal file
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* Haiku platform-dependent support routines for PhysicsFS.
|
||||
*
|
||||
* Please see the file LICENSE.txt in the source's root directory.
|
||||
*
|
||||
* This file written by Ryan C. Gordon.
|
||||
*/
|
||||
|
||||
#define __PHYSICSFS_INTERNAL__
|
||||
#include "physfs_platforms.h"
|
||||
|
||||
#ifdef PHYSFS_PLATFORM_HAIKU
|
||||
|
||||
#include <os/kernel/OS.h>
|
||||
#include <os/app/Roster.h>
|
||||
#include <os/storage/Volume.h>
|
||||
#include <os/storage/VolumeRoster.h>
|
||||
#include <os/storage/Directory.h>
|
||||
#include <os/storage/Entry.h>
|
||||
#include <os/storage/Path.h>
|
||||
#include <os/kernel/fs_info.h>
|
||||
#include <os/device/scsi.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "physfs_internal.h"
|
||||
|
||||
int __PHYSFS_platformInit(void)
|
||||
{
|
||||
return 1; /* always succeed. */
|
||||
} /* __PHYSFS_platformInit */
|
||||
|
||||
|
||||
void __PHYSFS_platformDeinit(void)
|
||||
{
|
||||
/* no-op */
|
||||
} /* __PHYSFS_platformDeinit */
|
||||
|
||||
|
||||
static char *getMountPoint(const char *devname, char *buf, size_t bufsize)
|
||||
{
|
||||
BVolumeRoster mounts;
|
||||
BVolume vol;
|
||||
|
||||
mounts.Rewind();
|
||||
while (mounts.GetNextVolume(&vol) == B_NO_ERROR)
|
||||
{
|
||||
fs_info fsinfo;
|
||||
fs_stat_dev(vol.Device(), &fsinfo);
|
||||
if (strcmp(devname, fsinfo.device_name) == 0)
|
||||
{
|
||||
BDirectory directory;
|
||||
BEntry entry;
|
||||
BPath path;
|
||||
const char *str;
|
||||
|
||||
if ( (vol.GetRootDirectory(&directory) < B_OK) ||
|
||||
(directory.GetEntry(&entry) < B_OK) ||
|
||||
(entry.GetPath(&path) < B_OK) ||
|
||||
( (str = path.Path()) == NULL) )
|
||||
return NULL;
|
||||
|
||||
strncpy(buf, str, bufsize-1);
|
||||
buf[bufsize-1] = '\0';
|
||||
return buf;
|
||||
} /* if */
|
||||
} /* while */
|
||||
|
||||
return NULL;
|
||||
} /* getMountPoint */
|
||||
|
||||
|
||||
/*
|
||||
* This function is lifted from Simple Directmedia Layer (SDL):
|
||||
* https://www.libsdl.org/ ... this is zlib-licensed code, too.
|
||||
*/
|
||||
static void tryDir(const char *d, PHYSFS_StringCallback callback, void *data)
|
||||
{
|
||||
BDirectory dir;
|
||||
dir.SetTo(d);
|
||||
if (dir.InitCheck() != B_NO_ERROR)
|
||||
return;
|
||||
|
||||
dir.Rewind();
|
||||
BEntry entry;
|
||||
while (dir.GetNextEntry(&entry) >= 0)
|
||||
{
|
||||
BPath path;
|
||||
const char *name;
|
||||
entry_ref e;
|
||||
|
||||
if (entry.GetPath(&path) != B_NO_ERROR)
|
||||
continue;
|
||||
|
||||
name = path.Path();
|
||||
|
||||
if (entry.GetRef(&e) != B_NO_ERROR)
|
||||
continue;
|
||||
|
||||
if (entry.IsDirectory())
|
||||
{
|
||||
if (strcmp(e.name, "floppy") != 0)
|
||||
tryDir(name, callback, data);
|
||||
continue;
|
||||
} /* if */
|
||||
|
||||
const int devfd = open(name, O_RDONLY);
|
||||
if (devfd < 0)
|
||||
continue;
|
||||
|
||||
device_geometry g;
|
||||
const int rc = ioctl(devfd, B_GET_GEOMETRY, &g, sizeof (g));
|
||||
close(devfd);
|
||||
if (rc < 0)
|
||||
continue;
|
||||
|
||||
if (g.device_type != B_CD)
|
||||
continue;
|
||||
|
||||
char mntpnt[B_FILE_NAME_LENGTH];
|
||||
if (getMountPoint(name, mntpnt, sizeof (mntpnt)))
|
||||
callback(data, mntpnt);
|
||||
} /* while */
|
||||
} /* tryDir */
|
||||
|
||||
|
||||
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||
{
|
||||
tryDir("/dev/disk", cb, data);
|
||||
} /* __PHYSFS_platformDetectAvailableCDs */
|
||||
|
||||
|
||||
static team_id getTeamID(void)
|
||||
{
|
||||
thread_info info;
|
||||
thread_id tid = find_thread(NULL);
|
||||
get_thread_info(tid, &info);
|
||||
return info.team;
|
||||
} /* getTeamID */
|
||||
|
||||
|
||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||
{
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
||||
{
|
||||
if (info.type == B_APP_IMAGE)
|
||||
break;
|
||||
} /* while */
|
||||
|
||||
BEntry entry(info.name, true);
|
||||
BPath path;
|
||||
status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */
|
||||
assert(rc == B_OK);
|
||||
rc = path.GetParent(&path); /* chop filename, keep directory. */
|
||||
assert(rc == B_OK);
|
||||
const char *str = path.Path();
|
||||
assert(str != NULL);
|
||||
const size_t len = strlen(str);
|
||||
char *retval = (char *) allocator.Malloc(len + 2);
|
||||
BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
|
||||
strcpy(retval, str);
|
||||
retval[len] = '/';
|
||||
retval[len+1] = '\0';
|
||||
return retval;
|
||||
} /* __PHYSFS_platformCalcBaseDir */
|
||||
|
||||
|
||||
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
|
||||
{
|
||||
const char *userdir = __PHYSFS_getUserDir();
|
||||
const char *append = "config/settings/";
|
||||
const size_t len = strlen(userdir) + strlen(append) + strlen(app) + 2;
|
||||
char *retval = (char *) allocator.Malloc(len);
|
||||
BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
|
||||
snprintf(retval, len, "%s%s%s/", userdir, append, app);
|
||||
return retval;
|
||||
} /* __PHYSFS_platformCalcPrefDir */
|
||||
|
||||
#endif /* PHYSFS_PLATFORM_HAIKU */
|
||||
|
||||
/* end of physfs_platform_haiku.cpp ... */
|
||||
|
Loading…
Reference in a new issue