2016-11-22 19:56:13 +00:00
|
|
|
//
|
|
|
|
// FileException.cpp
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by Paul Licameli on 11/22/16.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Audacity.h"
|
|
|
|
#include "FileException.h"
|
2018-11-11 02:40:37 +00:00
|
|
|
|
2017-10-17 11:18:38 +00:00
|
|
|
#include "Prefs.h"
|
2016-11-22 19:56:13 +00:00
|
|
|
|
|
|
|
FileException::~FileException()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FileException::ErrorMessage() const
|
|
|
|
{
|
|
|
|
wxString format;
|
|
|
|
switch (cause) {
|
|
|
|
case Cause::Open:
|
2017-07-18 00:44:49 +00:00
|
|
|
format = _("Audacity failed to open a file in %s.");
|
2016-11-22 19:56:13 +00:00
|
|
|
break;
|
|
|
|
case Cause::Read:
|
2017-07-18 00:44:49 +00:00
|
|
|
format = _("Audacity failed to read from a file in %s.");
|
2016-11-22 19:56:13 +00:00
|
|
|
break;
|
2017-10-17 14:32:09 +00:00
|
|
|
case Cause::Write:
|
|
|
|
format =
|
2017-10-17 11:18:38 +00:00
|
|
|
_("Audacity failed to write to a file.\n"
|
|
|
|
"Perhaps %s is not writable or the disk is full.");
|
2016-11-22 19:56:13 +00:00
|
|
|
break;
|
|
|
|
case Cause::Rename:
|
2017-07-18 00:44:49 +00:00
|
|
|
format =
|
|
|
|
_("Audacity successfully wrote a file in %s but failed to rename it as %s.");
|
2016-11-22 19:56:13 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-10-18 00:53:46 +00:00
|
|
|
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
|
|
|
|
|
2016-11-22 19:56:13 +00:00
|
|
|
return wxString::Format(
|
2017-07-18 00:44:49 +00:00
|
|
|
format, target, renameTarget.GetFullName() );
|
2016-11-22 19:56:13 +00:00
|
|
|
}
|
|
|
|
|