Skip to content

Commit

Permalink
Don't call exit() if creating user data directory fails
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisn committed Jun 28, 2020
1 parent c065836 commit 02d0498
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Src/beebwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ BeebWin::BeebWin()
m_DXSmoothing = true;
m_DXSmoothMode7Only = false;
m_DXResetPending = false;

m_JoystickCaptured = false;
m_customip[0] = 0;
m_customport = 0;
Expand Down Expand Up @@ -231,7 +232,7 @@ BeebWin::BeebWin()

// Read user data path from registry
if (!RegGetStringValue(HKEY_CURRENT_USER, CFG_REG_KEY, "UserDataFolder",
m_UserDataPath, _MAX_PATH))
m_UserDataPath, _MAX_PATH))
{
// Default user data path to a sub-directory in My Docs
if (SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, m_UserDataPath) == NOERROR)
Expand All @@ -242,7 +243,7 @@ BeebWin::BeebWin()

// Read disc images path from registry
if (!RegGetStringValue(HKEY_CURRENT_USER, CFG_REG_KEY, "DiscsPath",
m_DiscPath, _MAX_PATH))
m_DiscPath, _MAX_PATH))
{
// Default disc images path to a sub-directory of UserData path
strcpy(m_DiscPath, m_UserDataPath);
Expand All @@ -265,7 +266,7 @@ bool BeebWin::Initialise()

// Check that user data directory exists
if (!CheckUserDataPath())
exit(-1);
return false;

LoadPreferences();

Expand All @@ -277,7 +278,7 @@ bool BeebWin::Initialise()

if (FAILED(CoInitialize(NULL)))
{
MessageBox(m_hWnd,"Failed to initialise COM\n",WindowTitle,MB_OK|MB_ICONERROR);
MessageBox(m_hWnd, "Failed to initialise COM", WindowTitle, MB_OK | MB_ICONERROR);
return false;
}

Expand Down Expand Up @@ -4593,15 +4594,15 @@ bool BeebWin::CheckUserDataPath()
bool store_user_data_path = false;
char path[_MAX_PATH];
char errstr[500];
DWORD att;

// Change all '/' to '\'
for (unsigned int i = 0; i < strlen(m_UserDataPath); ++i)
for (size_t i = 0; i < strlen(m_UserDataPath); ++i)
if (m_UserDataPath[i] == '/')
m_UserDataPath[i] = '\\';

// Check that the folder exists
att = GetFileAttributes(m_UserDataPath);
DWORD att = GetFileAttributes(m_UserDataPath);

if (att == INVALID_FILE_ATTRIBUTES || !(att & FILE_ATTRIBUTE_DIRECTORY))
{
sprintf(errstr, "BeebEm data folder does not exist:\n %s\n\nCreate the folder?",
Expand Down

0 comments on commit 02d0498

Please sign in to comment.