Skip to content

Commit

Permalink
Xbox NXDK: Create pref path directory
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Jul 4, 2022
1 parent 9dae2d4 commit c0fcb17
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Source/utils/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <SDL.h>

#include "appfat.h"
#include "utils/file_util.h"
#include "utils/log.hpp"
#include "utils/sdl_ptrs.h"
Expand All @@ -10,6 +11,12 @@
#include "platform/ios/ios_paths.h"
#endif

#ifdef NXDK
#define NOMINMAX 1
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
#endif
Expand Down Expand Up @@ -50,6 +57,20 @@ std::string FromSDL(char *s)
return result;
}

#ifdef NXDK
const std::string &NxdkGetPrefPath()
{
static const std::string Path = []() {
const char *path = "E:\\devilutionx\\";
if (CreateDirectoryA(path, nullptr) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) {
DirErrorDlg(path);
}
return path;
}();
return Path;
}
#endif

} // namespace

const std::string &BasePath()
Expand All @@ -66,7 +87,7 @@ const std::string &PrefPath()
#if defined(__IPHONEOS__)
prefPath = FromSDL(IOSGetPrefPath());
#elif defined(NXDK)
prefPath = std::string("E:\\devilutionx\\");
prefPath = NxdkGetPrefPath();
#else
prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
if (FileExistsAndIsWriteable("diablo.ini")) {
Expand All @@ -83,7 +104,7 @@ const std::string &ConfigPath()
#if defined(__IPHONEOS__)
configPath = FromSDL(IOSGetPrefPath());
#elif defined(NXDK)
configPath = std::string("E:\\devilutionx\\");
configPath = NxdkGetPrefPath();
#else
configPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
if (FileExistsAndIsWriteable("diablo.ini")) {
Expand Down

0 comments on commit c0fcb17

Please sign in to comment.