test that song dir is writable before loading it in editor

This commit is contained in:
Chris Danford
2006-06-19 00:00:47 +00:00
parent 8b7a511e99
commit e3627c7377
2 changed files with 21 additions and 1 deletions
+2 -1
View File
@@ -333,7 +333,7 @@ Player2Profile=
PreloadSounds=If YES, preload most sounds in advance. This increases load times, and should normally be left OFF.
Premium=Premium
Profile=
Profiles=Edit the player profile stored on this machine.
Profiles=Edit the player profiles stored on this machine.
ProgressiveLifebar=Set whether the lifebar is harsher on consecutive boo/miss judgments. OFF for no effect, 8 to make each consecutive miss a multiple of the first miss.
ProgressiveNonstopLifebar=Determine whether the lifebar gets harsher as a nonstop course progresses. LifeDifficulty + this = Lifedifficulty on a final stage of a course.
ProgressiveStageLifebar=Determine whether the lifebar gets harsher on later stages. LifeDifficulty + this = Lifedifficulty on a final stage. Has no effect on event mode.
@@ -1052,6 +1052,7 @@ Profile name cannot be blank.=Profile name can not be blank.
The name you chose conflicts with another profile. Please use a different name.=The name you chose conflicts with another profile. Please use a different name.
These steps will be lost permanently.=These steps will be lost permanently.
This song is missing a music file and cannot be edited.=This song is missing a music file and can not be edited.
The song directory is read-only and cannot be edited.=The song directory is read-only and cannot be edited.
Blank=Blank
[ScreenEditOptions]
+19
View File
@@ -16,6 +16,10 @@
#include "ScreenPrompt.h"
#include "LocalizedString.h"
#include "SongUtil.h"
#include "RageFile.h"
#include "RageFileManager.h"
static const RString TEMP_FILE_NAME = "--temp--";
#define EXPLANATION_TEXT( row ) THEME->GetString(m_sName,"Explanation"+EditMenuRowToString(row))
#define EDIT_MENU_TYPE THEME->GetMetric(m_sName,"EditMenuType")
@@ -152,6 +156,7 @@ static void DeleteCurrentSteps()
}
static LocalizedString MISSING_MUSIC_FILE ( "ScreenEditMenu", "This song is missing a music file and cannot be edited." );
static LocalizedString SONG_DIR_READ_ONLY ( "ScreenEditMenu", "The song directory is read-only and cannot be edited." );
static LocalizedString STEPS_WILL_BE_LOST ( "ScreenEditMenu", "These steps will be lost permanently." );
static LocalizedString CONTINUE_WITH_DELETE ( "ScreenEditMenu", "Continue with delete?" );
static LocalizedString BLANK ( "ScreenEditMenu", "Blank" );
@@ -191,6 +196,20 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
return;
}
{
RString sDir = pSong->GetSongDir();
RString sTempFile = sDir + TEMP_FILE_NAME;
RageFile file;
if( !file.Open( sTempFile, RageFile::WRITE ) )
{
ScreenPrompt::Prompt( SM_None, SONG_DIR_READ_ONLY );
return;
}
file.Close();
FILEMAN->Remove( sTempFile );
}
//
// Do work
//