summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-10-15 21:53:46 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-10-15 21:53:46 +0300
commit77a8bff2440d742e42d7e991a38d0e6ffa07ed0f (patch)
treec88e5c95e352a299154aaa113c83154a837d9a15 /src/app.c
parent5fdbd18485bf487f3775e52aed1f4a18870a3acc (diff)
Determining app executable location
IssueID #9
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/app.c b/src/app.c
index eb48d13f..ddd0084f 100644
--- a/src/app.c
+++ b/src/app.c
@@ -46,6 +46,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
46#include <the_Foundation/sortedarray.h> 46#include <the_Foundation/sortedarray.h>
47#include <the_Foundation/time.h> 47#include <the_Foundation/time.h>
48#include <SDL_events.h> 48#include <SDL_events.h>
49#include <SDL_filesystem.h>
49#include <SDL_render.h> 50#include <SDL_render.h>
50#include <SDL_timer.h> 51#include <SDL_timer.h>
51#include <SDL_video.h> 52#include <SDL_video.h>
@@ -82,6 +83,7 @@ static const char *downloadDir_App_ = "~/Downloads";
82 83
83struct Impl_App { 84struct Impl_App {
84 iCommandLine args; 85 iCommandLine args;
86 iString * execPath;
85 iGmCerts * certs; 87 iGmCerts * certs;
86 iVisited * visited; 88 iVisited * visited;
87 iBookmarks * bookmarks; 89 iBookmarks * bookmarks;
@@ -313,12 +315,23 @@ static void init_App_(iApp *d, int argc, char **argv) {
313 d->launchCommands = new_StringList(); 315 d->launchCommands = new_StringList();
314 iZap(d->lastDropTime); 316 iZap(d->lastDropTime);
315 init_CommandLine(&d->args, argc, argv); 317 init_CommandLine(&d->args, argc, argv);
318 /* Where was the app started from? */ {
319 char *exec = SDL_GetBasePath();
320 if (exec) {
321 d->execPath = newCStr_String(concatPath_CStr(
322 exec, cstr_Rangecc(baseName_Path(executablePath_CommandLine(&d->args)))));
323 }
324 else {
325 d->execPath = copy_String(executablePath_CommandLine(&d->args));
326 }
327 SDL_free(exec);
328 }
316 init_SortedArray(&d->tickers, sizeof(iTicker), cmp_Ticker_); 329 init_SortedArray(&d->tickers, sizeof(iTicker), cmp_Ticker_);
317 d->lastTickerTime = SDL_GetTicks(); 330 d->lastTickerTime = SDL_GetTicks();
318 d->elapsedSinceLastTicker = 0; 331 d->elapsedSinceLastTicker = 0;
319 d->commandEcho = checkArgument_CommandLine(&d->args, "echo") != NULL; 332 d->commandEcho = checkArgument_CommandLine(&d->args, "echo") != NULL;
320 d->forceSoftwareRender = checkArgument_CommandLine(&d->args, "sw") != NULL; 333 d->forceSoftwareRender = checkArgument_CommandLine(&d->args, "sw") != NULL;
321 d->initialWindowRect = init_Rect(-1, -1, 900, 560); 334 d->initialWindowRect = init_Rect(-1, -1, 900, 560);
322#if defined (iPlatformMsys) 335#if defined (iPlatformMsys)
323 /* Must scale by UI scaling factor. */ 336 /* Must scale by UI scaling factor. */
324 mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32()); 337 mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32());
@@ -417,10 +430,11 @@ static void deinit_App(iApp *d) {
417 d->window = NULL; 430 d->window = NULL;
418 deinit_CommandLine(&d->args); 431 deinit_CommandLine(&d->args);
419 iRelease(d->launchCommands); 432 iRelease(d->launchCommands);
433 delete_String(d->execPath);
420} 434}
421 435
422const iString *execPath_App(void) { 436const iString *execPath_App(void) {
423 return executablePath_CommandLine(&app_.args); 437 return app_.execPath;
424} 438}
425 439
426const iString *dataDir_App(void) { 440const iString *dataDir_App(void) {