Audacity  2.2.2
FileException.cpp
Go to the documentation of this file.
1 //
2 // FileException.cpp
3 //
4 //
5 // Created by Paul Licameli on 11/22/16.
6 //
7 //
8 
9 #include "Audacity.h"
10 #include "FileException.h"
11 #include "Internat.h"
12 #include "Prefs.h"
13 
15 {
16 }
17 
18 std::unique_ptr< AudacityException > FileException::Move()
19 {
20  return std::unique_ptr< AudacityException >
21  { safenew FileException{ std::move( *this ) } };
22 }
23 
25 {
26  wxString format;
27  switch (cause) {
28  case Cause::Open:
29  format = _("Audacity failed to open a file in %s.");
30  break;
31  case Cause::Read:
32  format = _("Audacity failed to read from a file in %s.");
33  break;
34  case Cause::Write:
35  format =
36 _("Audacity failed to write to a file.\n"
37  "Perhaps %s is not writable or the disk is full.");
38  break;
39  case Cause::Rename:
40  format =
41 _("Audacity successfully wrote a file in %s but failed to rename it as %s.");
42  default:
43  break;
44  }
45  wxString target;
46 
47 #ifdef __WXMSW__
48 
49  // Drive letter plus colon
50  target = fileName.GetVolume() + wxT(":");
51 
52 #else
53 
54  // Shorten the path, arbitrarily to 3 components
55  auto path = fileName;
56  path.SetFullName(wxString{});
57  while(path.GetDirCount() > 3)
58  path.RemoveLastDir();
59  target = path.GetFullPath();
60 
61 #endif
62 
63  return wxString::Format(
64  format, target, renameTarget.GetFullName() );
65 }
66 
wxFileName renameTarget
Definition: FileException.h:48
std::unique_ptr< AudacityException > Move() override
#define safenew
Definition: Audacity.h:223
int format
Definition: ExportPCM.cpp:56
wxFileName fileName
Definition: FileException.h:47
wxString ErrorMessage() const override
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
~FileException() override