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();
|
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 FileNames::DefaultToDocumentsFolder(const wxString &preference)
|
||||||
{
|
{
|
||||||
wxFileNameWrapper result;
|
wxFileNameWrapper result;
|
||||||
@ -380,18 +392,18 @@ wxFileNameWrapper FileNames::DefaultToDocumentsFolder(const wxString &preference
|
|||||||
result.SetPath( gPrefs->Read( preference, defaultPath.GetPath( wxPATH_GET_VOLUME ) ) );
|
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
|
// 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( !bIsDefaultPath )
|
||||||
{
|
{
|
||||||
// IF the prefs directory doesn't exist - (Deleted by our user perhaps?)
|
// IF the prefs directory doesn't exist - (Deleted by our user perhaps?)
|
||||||
// or exists as a file
|
// or exists as a file
|
||||||
// THEN fallback to using the default directory.
|
// THEN fallback to using the default directory.
|
||||||
bIsDefaultPath = !result.DirExists() || result.FileExists();
|
bIsDefaultPath = !IsPathAvailable( result.GetPath(wxPATH_GET_VOLUME ) );
|
||||||
if( bIsDefaultPath )
|
if( bIsDefaultPath )
|
||||||
{
|
{
|
||||||
result.SetPath( defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
result.SetPath( defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
||||||
gPrefs->Write( preference, defaultPath.GetPath( wxPATH_GET_VOLUME ) );
|
// Don't write to gPrefs.
|
||||||
gPrefs->Flush();
|
// We typically do it later, (if directory actually gets used)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( bIsDefaultPath )
|
if ( bIsDefaultPath )
|
||||||
|
@ -78,6 +78,7 @@ public:
|
|||||||
// Obtain name of loaded module that contains address
|
// Obtain name of loaded module that contains address
|
||||||
static FilePath PathFromAddr(void *addr);
|
static FilePath PathFromAddr(void *addr);
|
||||||
|
|
||||||
|
static bool IsPathAvailable( const FilePath & Path);
|
||||||
static wxFileNameWrapper DefaultToDocumentsFolder
|
static wxFileNameWrapper DefaultToDocumentsFolder
|
||||||
(const wxString &preference);
|
(const wxString &preference);
|
||||||
|
|
||||||
|
@ -4404,7 +4404,7 @@ bool AudacityProject::SaveAs(bool bWantSaveCopy /*= false*/, bool bLossless /*=
|
|||||||
bWantSaveCopy = true;
|
bWantSaveCopy = true;
|
||||||
|
|
||||||
// Bug 1304: Set a default file path if none was given. For Save/SaveAs
|
// 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;
|
bHasPath = false;
|
||||||
filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path"));
|
filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user