MCPcopy Create free account
hub / github.com/TASEmulators/fceux / emu_getdir

Function emu_getdir

src/lua-engine.cpp:555–609  ·  view source on GitHub ↗

emu.getdir() Returns the path of fceux.exe as a string.

Source from the content-addressed store, hash-verified

553//
554// Returns the path of fceux.exe as a string.
555static int emu_getdir(lua_State *L) {
556#ifdef WIN32
557 char fullPath[2048];
558 char driveLetter[3];
559 char directory[2048];
560 char finalPath[2048];
561
562 GetModuleFileNameA(NULL, fullPath, 2048);
563 _splitpath(fullPath, driveLetter, directory, NULL, NULL);
564 snprintf(finalPath, sizeof(finalPath), "%s%s", driveLetter, directory);
565 lua_pushstring(L, finalPath);
566
567 return 1;
568#elif __linux__
569 char exePath[ 2048 ];
570 ssize_t count = ::readlink( "/proc/self/exe", exePath, sizeof(exePath)-1 );
571
572 if ( count > 0 )
573 {
574 char *dir;
575 exePath[count] = 0;
576 //printf("EXE Path: '%s' \n", exePath );
577
578 dir = ::dirname( exePath );
579
580 if ( dir )
581 {
582 //printf("DIR Path: '%s' \n", dir );
583 lua_pushstring(L, dir);
584 return 1;
585 }
586 }
587#elif __APPLE__
588 char exePath[ 2048 ];
589 uint32_t bufSize = sizeof(exePath);
590 int result = _NSGetExecutablePath( exePath, &bufSize );
591
592 if ( result == 0 )
593 {
594 char *dir;
595 exePath[ sizeof(exePath)-1 ] = 0;
596 //printf("EXE Path: '%s' \n", exePath );
597
598 dir = ::dirname( exePath );
599
600 if ( dir )
601 {
602 //printf("DIR Path: '%s' \n", dir );
603 lua_pushstring(L, dir);
604 return 1;
605 }
606 }
607#endif
608 return 0;
609}
610
611
612extern void ReloadRom(void);

Callers

nothing calls this directly

Calls 1

lua_pushstringFunction · 0.85

Tested by

no test coverage detected