forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileException.cpp
More file actions
60 lines (50 loc) · 1.21 KB
/
Copy pathFileException.cpp
File metadata and controls
60 lines (50 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// FileException.cpp
//
//
// Created by Paul Licameli on 11/22/16.
//
//
#include "Audacity.h"
#include "FileException.h"
#include "Internat.h"
#include "Prefs.h"
FileException::~FileException()
{
}
wxString FileException::ErrorMessage() const
{
wxString format;
switch (cause) {
case Cause::Open:
format = _("Audacity failed to open a file in %s.");
break;
case Cause::Read:
format = _("Audacity failed to read from a file in %s.");
break;
case Cause::Write:
format =
_("Audacity failed to write to a file.\n"
"Perhaps %s is not writable or the disk is full.");
break;
case Cause::Rename:
format =
_("Audacity successfully wrote a file in %s but failed to rename it as %s.");
default:
break;
}
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 wxString::Format(
format, target, renameTarget.GetFullName() );
}