Skip to content

Commit 2636c92

Browse files
Warr1024ShadowNinja
authored andcommittedNov 2, 2013
Portability fixes for OpenBSD (and possibly NetBSD and others).
1 parent d11c76b commit 2636c92

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎src/porting.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,13 @@ void initializePaths()
373373
//TODO: Get path of executable. This assumes working directory is bin/
374374
dstream<<"WARNING: Relative path not properly supported on this platform"
375375
<<std::endl;
376-
path_share = std::string("..");
377-
path_user = std::string("..");
376+
377+
/* scriptapi no longer allows paths that start with "..", so assuming that
378+
the current working directory is bin/, strip off the last component. */
379+
char *cwd = getcwd(NULL, 0);
380+
pathRemoveFile(cwd, '/');
381+
path_share = std::string(cwd);
382+
path_user = std::string(cwd);
378383

379384
#endif
380385

@@ -477,7 +482,7 @@ void initializePaths()
477482

478483
path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;
479484

480-
#elif defined(__FreeBSD__)
485+
#else // FreeBSD, and probably many other POSIX-like systems.
481486

482487
path_share = STATIC_SHAREDIR;
483488
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;

0 commit comments

Comments
 (0)
Please sign in to comment.