mirror of https://github.com/mgba-emu/mgba.git
GBA Config: Check current directory for portable.ini
This commit is contained in:
parent
27898fb1f3
commit
06f02ef873
1
CHANGES
1
CHANGES
|
@ -22,6 +22,7 @@ Features:
|
||||||
- Holdable shortcut for rewinding one frame at a time
|
- Holdable shortcut for rewinding one frame at a time
|
||||||
- Ability to boot directly into the BIOS
|
- Ability to boot directly into the BIOS
|
||||||
- Preliminary support for yanking out the game pak while a game is running
|
- Preliminary support for yanking out the game pak while a game is running
|
||||||
|
- Thumb-drive mode by putting a file called portable.ini in the same folder
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- ARM7: Fix SWI and IRQ timings
|
- ARM7: Fix SWI and IRQ timings
|
||||||
- GBA Audio: Force audio FIFOs to 32-bit
|
- GBA Audio: Force audio FIFOs to 32-bit
|
||||||
|
|
|
@ -168,7 +168,7 @@ find_feature(USE_MAGICK "MagickWand")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}")
|
set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}")
|
||||||
add_definitions(-D_WIN32_WINNT=0x0600)
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
||||||
list(APPEND OS_LIB ws2_32)
|
list(APPEND OS_LIB ws2_32 shlwapi)
|
||||||
list(APPEND VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
|
list(APPEND VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
|
||||||
file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
|
file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
|
||||||
source_group("Windows-specific code" FILES ${OS_SRC})
|
source_group("Windows-specific code" FILES ${OS_SRC})
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -126,21 +127,41 @@ bool GBAConfigSave(const struct GBAConfig* config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAConfigDirectory(char* out, size_t outLength) {
|
void GBAConfigDirectory(char* out, size_t outLength) {
|
||||||
|
struct VFile* portable;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
getcwd(out, outLength);
|
||||||
|
strncat(out, PATH_SEP "portable.ini", outLength - strlen(out));
|
||||||
|
portable = VFileOpen(out, O_RDONLY);
|
||||||
|
if (portable) {
|
||||||
|
getcwd(out, outLength);
|
||||||
|
portable->close(portable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char* home = getenv("HOME");
|
char* home = getenv("HOME");
|
||||||
snprintf(out, outLength, "%s/.config", home);
|
snprintf(out, outLength, "%s/.config", home);
|
||||||
mkdir(out, 0755);
|
mkdir(out, 0755);
|
||||||
snprintf(out, outLength, "%s/.config/%s", home, binaryName);
|
snprintf(out, outLength, "%s/.config/%s", home, binaryName);
|
||||||
mkdir(out, 0755);
|
mkdir(out, 0755);
|
||||||
#else
|
#else
|
||||||
wchar_t* home;
|
|
||||||
wchar_t wpath[MAX_PATH];
|
wchar_t wpath[MAX_PATH];
|
||||||
wchar_t wprojectName[MAX_PATH];
|
wchar_t wprojectName[MAX_PATH];
|
||||||
SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &home);
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, projectName, -1, wprojectName, MAX_PATH);
|
MultiByteToWideChar(CP_UTF8, 0, projectName, -1, wprojectName, MAX_PATH);
|
||||||
StringCchPrintfW(wpath, MAX_PATH, L"%ws\\%ws", home, wprojectName);
|
HMODULE hModule = GetModuleHandleW(NULL);
|
||||||
CoTaskMemFree(home);
|
GetModuleFileNameW(hModule, wpath, MAX_PATH);
|
||||||
CreateDirectoryW(wpath, NULL);
|
PathRemoveFileSpecW(wpath);
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0);
|
||||||
|
StringCchCatA(out, outLength, "\\portable.ini");
|
||||||
|
portable = VFileOpen(out, O_RDONLY);
|
||||||
|
if (portable) {
|
||||||
|
portable->close(portable);
|
||||||
|
} else {
|
||||||
|
wchar_t* home;
|
||||||
|
SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &home);
|
||||||
|
StringCchPrintfW(wpath, MAX_PATH, L"%ws\\%ws", home, wprojectName);
|
||||||
|
CoTaskMemFree(home);
|
||||||
|
CreateDirectoryW(wpath, NULL);
|
||||||
|
}
|
||||||
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0);
|
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue