mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
Bug 1899 - Windows: previously deleted folders are unnecessarily re-created on next Save
This commit is contained in:
parent
d994ad430a
commit
44fde0a90f
@ -370,20 +370,39 @@ FilePath FileNames::PathFromAddr(void *addr)
|
|||||||
return name.GetFullPath();
|
return name.GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileNameWrapper FileNames::DefaultToDocumentsFolder
|
wxFileNameWrapper FileNames::DefaultToDocumentsFolder(const wxString &preference)
|
||||||
(const wxString &preference)
|
|
||||||
{
|
{
|
||||||
wxFileNameWrapper result;
|
wxFileNameWrapper result;
|
||||||
result.AssignHomeDir();
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
result.SetPath(gPrefs->Read(
|
wxFileName defaultPath( wxStandardPaths::Get().GetDocumentsDir(), "" );
|
||||||
preference, result.GetPath(wxPATH_GET_VOLUME) + "\\Documents\\Audacity"));
|
defaultPath.AppendDir( wxGetApp().GetAppName() );
|
||||||
// The path might not exist.
|
result.SetPath( gPrefs->Read( preference, defaultPath.GetPath( wxPATH_GET_VOLUME ) ) );
|
||||||
|
|
||||||
|
// MJB: Bug 1899 & Bug 2007. Only create directory if the result is the default path
|
||||||
|
bool bIsDefaultPath = result == defaultPath;
|
||||||
|
if( !bIsDefaultPath )
|
||||||
|
{
|
||||||
|
// IF the prefs directory doesn't exist - (Deleted by our user perhaps?)
|
||||||
|
// or exists as a file
|
||||||
|
// THEN fallback to using the default directory.
|
||||||
|
bIsDefaultPath = !result.DirExists() || result.FileExists();
|
||||||
|
if( bIsDefaultPath )
|
||||||
|
{
|
||||||
|
result.SetPath( defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
||||||
|
gPrefs->Write( preference, defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
||||||
|
gPrefs->Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( bIsDefaultPath )
|
||||||
|
{
|
||||||
|
// The default path might not exist since it is a sub-directory of 'Documents'
|
||||||
// There is no error if the path could not be created. That's OK.
|
// There is no error if the path could not be created. That's OK.
|
||||||
// The dialog that Audacity offers will allow the user to select a valid directory.
|
// The dialog that Audacity offers will allow the user to select a valid directory.
|
||||||
result.Mkdir(0755, wxPATH_MKDIR_FULL);
|
result.Mkdir(0755, wxPATH_MKDIR_FULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
result.AssignHomeDir();
|
||||||
result.SetPath(gPrefs->Read( preference, result.GetPath() + "/Documents"));
|
result.SetPath(gPrefs->Read( preference, result.GetPath() + "/Documents"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user