MCPcopy Create free account
hub / github.com/audacity/audacity / VerifyFilename

Function VerifyFilename

libraries/lib-wx-init/SelectFile.cpp:45–81  ·  view source on GitHub ↗

On Windows, wxString::mb_str() can return a NULL pointer if the conversion to multi-byte fails. So, based on direction intent, returns a pointer to an empty string or prompts for a NEW name.

Source from the content-addressed store, hash-verified

43// returns a pointer to an empty string or prompts for a NEW name.
44//
45char *VerifyFilename(const wxString &s, bool input)
46{
47 static wxCharBuffer buf;
48 wxString name = s;
49
50 if (input) {
51 if ((char *) (const char *)name.mb_str() == NULL) {
52 name = wxEmptyString;
53 }
54 }
55 else {
56 wxFileName ff(name);
57 FileExtension ext;
58 while ((char *) (const char *)name.mb_str() == NULL) {
59 AudacityMessageBox(
60 XO(
61"The specified filename could not be converted due to Unicode character use."));
62
63 ext = ff.GetExt();
64 name = SelectFile(FileNames::Operation::_None,
65 XO("Specify New Filename:"),
66 wxEmptyString,
67 name,
68 ext,
69 { ext.empty()
70 ? FileNames::AllFiles
71 : FileNames::FileType{ {}, { ext } }
72 },
73 wxFD_SAVE | wxRESIZE_BORDER,
74 wxGetTopLevelParent(NULL));
75 }
76 }
77
78 mFilename = name.mb_str();
79
80 return (char *) (const char *) mFilename;
81}
82#endif

Callers

nothing calls this directly

Calls 3

AudacityMessageBoxFunction · 0.85
SelectFileFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected