mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Bug 1899 - Enh: Windows: previously deleted folders are unnecessarily re-created on next Save
Now checks for unusable path before prompting the user.
This commit is contained in:
parent
37e61ab1c2
commit
4e9b6582b6
@ -370,6 +370,18 @@ FilePath FileNames::PathFromAddr(void *addr)
|
||||
return name.GetFullPath();
|
||||
}
|
||||
|
||||
|
||||
bool FileNames::IsPathAvailable( const FilePath & Path){
|
||||
if( Path.IsEmpty() )
|
||||
return false;
|
||||
#ifndef __WIN32__
|
||||
return true;
|
||||
#else
|
||||
wxFileNameWrapper filePath( Path );
|
||||
return filePath.DirExists() && !filePath.FileExists();
|
||||
#endif
|
||||
}
|
||||
|
||||
wxFileNameWrapper FileNames::DefaultToDocumentsFolder(const wxString &preference)
|
||||
{
|
||||
wxFileNameWrapper result;
|
||||
@ -380,18 +392,18 @@ wxFileNameWrapper FileNames::DefaultToDocumentsFolder(const wxString &preference
|
||||
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;
|
||||
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();
|
||||
bIsDefaultPath = !IsPathAvailable( result.GetPath(wxPATH_GET_VOLUME ) );
|
||||
if( bIsDefaultPath )
|
||||
{
|
||||
result.SetPath( defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
||||
gPrefs->Write( preference, defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
||||
gPrefs->Flush();
|
||||
// Don't write to gPrefs.
|
||||
// We typically do it later, (if directory actually gets used)
|
||||
}
|
||||
}
|
||||
if ( bIsDefaultPath )
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
// Obtain name of loaded module that contains address
|
||||
static FilePath PathFromAddr(void *addr);
|
||||
|
||||
static bool IsPathAvailable( const FilePath & Path);
|
||||
static wxFileNameWrapper DefaultToDocumentsFolder
|
||||
(const wxString &preference);
|
||||
|
||||
|
@ -4404,7 +4404,7 @@ bool AudacityProject::SaveAs(bool bWantSaveCopy /*= false*/, bool bLossless /*=
|
||||
bWantSaveCopy = true;
|
||||
|
||||
// Bug 1304: Set a default file path if none was given. For Save/SaveAs
|
||||
if( filename.GetFullPath().empty() ){
|
||||
if( !FileNames::IsPathAvailable( filename.GetFullPath() ) ){
|
||||
bHasPath = false;
|
||||
filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user