From ced16a3cf56eef1cc362b380457a583307e05846 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 2 Oct 2005 04:54:09 +0000 Subject: [PATCH] troubleshooting failed directory create on some machines --- stepmania/src/smpackage/MainMenuDlg.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/stepmania/src/smpackage/MainMenuDlg.cpp b/stepmania/src/smpackage/MainMenuDlg.cpp index 2870ca56f0..2e0800379d 100644 --- a/stepmania/src/smpackage/MainMenuDlg.cpp +++ b/stepmania/src/smpackage/MainMenuDlg.cpp @@ -131,13 +131,26 @@ void MainMenuDlg::OnCreateSong() BOOL bSuccess; CString sSongDirectory = "Songs\\My Creations\\"; - CreateDirectory( sSongDirectory, NULL ); // ok if this fails. It will already exist if we've created another song. - DWORD dwError = ::GetLastError(); + bSuccess = CreateDirectory( sSongDirectory, NULL ); + if( !bSuccess ) + { + DWORD dwError = ::GetLastError(); + switch( dwError ) + { + case ERROR_ALREADY_EXISTS: + // This failure is ok. We probably created this directory already while importing another song. + break; + default: + MessageBox( "Failed to create directory '" + sSongDirectory + "': " + GetLastErrorString() ); + return; + } + } + sSongDirectory += sFileNameNoExt; bSuccess = CreateDirectory( sSongDirectory, NULL ); // CreateDirectory doesn't like a trailing slash if( !bSuccess ) { - MessageBox( "Failed to song directory '" + sSongDirectory + "': " + GetLastErrorString() ); + MessageBox( "Failed to create song directory '" + sSongDirectory + "': " + GetLastErrorString() ); return; } sSongDirectory += "\\";