1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-07 06:55:52 +01:00

Move AbbreviatePath to FileNames

This commit is contained in:
Paul Licameli
2020-12-06 14:53:35 -05:00
parent f07fd5d8bc
commit 4e260389da
6 changed files with 31 additions and 28 deletions

View File

@@ -9,6 +9,7 @@
#include "Audacity.h"
#include "FileException.h"
#include "FileNames.h"
#include "Prefs.h"
@@ -36,7 +37,7 @@ XO("Audacity successfully wrote a file in %s but failed to rename it as %s.");
}
return format.Format(
AbbreviatePath(fileName), renameTarget.GetFullName() );
FileNames::AbbreviatePath(fileName), renameTarget.GetFullName() );
}
wxString FileException::ErrorHelpUrl() const
@@ -56,33 +57,11 @@ wxString FileException::ErrorHelpUrl() const
return "";
}
wxString FileException::AbbreviatePath( const wxFileName &fileName )
{
wxString target;
#ifdef __WXMSW__
// Drive letter plus colon
target = fileName.GetVolume() + wxT(":");
#else
// Shorten the path, arbitrarily to 3 components
auto path = fileName;
path.SetFullName(wxString{});
while(path.GetDirCount() > 3)
path.RemoveLastDir();
target = path.GetFullPath();
#endif
return target;
}
TranslatableString
FileException::WriteFailureMessage(const wxFileName &fileName)
{
return XO("Audacity failed to write to a file.\n"
"Perhaps %s is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
).Format(AbbreviatePath(fileName));
).Format(FileNames::AbbreviatePath(fileName));
}