Skip to content

Commit

Permalink
Remove glfmGetDirectoryPath() function
Browse files Browse the repository at this point in the history
  • Loading branch information
brackeen committed Dec 2, 2017
1 parent 8ebbf36 commit ed2ef80
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 93 deletions.
13 changes: 0 additions & 13 deletions include/glfm.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ typedef enum {
GLFMKeyActionReleased,
} GLFMKeyAction;

typedef enum {
/// Directory where the executable and assets are located. Read-only.
GLFMDirectoryApp,
/// Directory where application documents can be saved. Read/write, and backed up.
GLFMDirectoryDocuments,
} GLFMDirectory;

// MARK: Structs and function pointers

typedef struct GLFMDisplay GLFMDisplay;
Expand Down Expand Up @@ -371,12 +364,6 @@ void glfmSetKeyboardVisibilityChangedFunc(GLFMDisplay *display,
/// This function never returns NULL. If the language cannot be determined, returns "en".
const char *glfmGetLanguage(void);

/// Gets a specified directory path. At app start, the current working directory is
/// `GLFMDirectoryApp`, where assets are located. For `GLFMDirectoryDocuments` on Emscripten,
/// which uses IndexedDB to store files, this function may return `NULL` if the virtual filesystem
/// hasn't been mounted yet.
const char *glfmGetDirectoryPath(GLFMDirectory directory);

#if defined(GLFM_PLATFORM_ANDROID)

#include <android/native_activity.h>
Expand Down
14 changes: 0 additions & 14 deletions src/glfm_platform_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,18 +1425,4 @@ ANativeActivity *glfmAndroidGetActivity() {
}
}

// MARK: GLFM Asset reading

const char *glfmGetDirectoryPath(GLFMDirectory directory) {
if (directory == GLFMDirectoryDocuments) {
if (platformDataGlobal && platformDataGlobal->app && platformDataGlobal->app->activity) {
return platformDataGlobal->app->activity->internalDataPath;
} else {
return NULL;
}
} else {
return "";
}
}

#endif
39 changes: 0 additions & 39 deletions src/glfm_platform_emscripten.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,8 @@ typedef struct {

static void _glfmClearActiveTouches(GLFMPlatformData *platformData);

static bool _glfmFileSystemMounted = false;

// MARK: GLFM implementation

const char *glfmGetDirectoryPath(GLFMDirectory directory) {
if (directory == GLFMDirectoryDocuments) {
return _glfmFileSystemMounted ? "/.local/share" : NULL;
} else {
return "/";
}
}

void glfmSetUserInterfaceOrientation(GLFMDisplay *display,
GLFMUserInterfaceOrientation allowedOrientations) {
if (display->allowedOrientations != allowedOrientations) {
Expand Down Expand Up @@ -203,35 +193,6 @@ GLFMProc glfmGetProcAddress(const char *functionName) {
return eglGetProcAddress(functionName);
}

// MARK: Filesystem

static void _glfmInitFS() {
_glfmFileSystemMounted = false;
EM_ASM(
FS.mkdir("/.glfm_documents");
FS.mount(IDBFS, {}, "/.glfm_documents");
FS.syncfs(true, function (err) {
ccall('_glfmSyncFSComplete', 'v');
});
);
}

static void _glfmSyncFS() {
if (_glfmFileSystemMounted) {
_glfmFileSystemMounted = false;
EM_ASM(
FS.syncfs(function (err) {
ccall('_glfmSyncFSComplete', 'v');
});
);
}
}

EMSCRIPTEN_KEEPALIVE
static void _glfmSyncFSComplete() {
_glfmFileSystemMounted = true;
}

// MARK: Emscripten glue

static int _glfmGetDisplayWidth(GLFMDisplay *display) {
Expand Down
27 changes: 0 additions & 27 deletions src/glfm_platform_ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ - (id)init {
[self clearTouches];
_glfmDisplay = calloc(1, sizeof(GLFMDisplay));
_glfmDisplay->platformData = (__bridge void *)self;
const char *path = glfmGetDirectoryPath(GLFMDirectoryApp);
if (path) {
chdir(path);
}
}
return self;
}
Expand Down Expand Up @@ -826,29 +822,6 @@ int main(int argc, char *argv[]) {

#pragma mark - GLFM implementation

const char *glfmGetDirectoryPath(GLFMDirectory directory) {
static char *appPath = NULL;
static char *docPath = NULL;

switch (directory) {
case GLFMDirectoryApp: default:
if (!appPath) {
appPath = strdup([NSBundle mainBundle].bundlePath.fileSystemRepresentation);
}
return appPath;
case GLFMDirectoryDocuments:
if (!docPath) {
NSArray<NSString *> *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
if (path.count > 0) {
docPath = strdup(path[0].fileSystemRepresentation);
}
}
return docPath;
}
}

GLFMProc glfmGetProcAddress(const char *functionName) {
static void *handle = NULL;
if (!handle) {
Expand Down

0 comments on commit ed2ef80

Please sign in to comment.