Audacity 3.2.0
Namespaces | Macros | Typedefs | Functions
SelectFile.h File Reference
#include "Identifier.h"
#include <vector>
Include dependency graph for SelectFile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


namespace  FileNames


#define OSINPUT(X)   VerifyFilename(X, true)
#define OSOUTPUT(X)   VerifyFilename(X, false)


using FileTypes = std::vector< FileNames::FileType >


WX_INIT_API FilePath SelectFile (FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
WX_INIT_API char * VerifyFilename (const wxString &s, bool input=true)
 Protect against Unicode to multi-byte conversion failures on Windows. More...

Detailed Description

Audacity: A Digital Audio Editor

Paul Licameli split from FileNames.h

Definition in file SelectFile.h.

Macro Definition Documentation


#define OSINPUT (   X)    VerifyFilename(X, true)

Definition at line 47 of file SelectFile.h.


#define OSOUTPUT (   X)    VerifyFilename(X, false)

Definition at line 48 of file SelectFile.h.

Typedef Documentation

◆ FileTypes

using FileTypes = std::vector< FileNames::FileType >

Definition at line 23 of file SelectFile.h.

Function Documentation

◆ SelectFile()

WX_INIT_API FilePath SelectFile ( FileNames::Operation  op,
const TranslatableString message,
const FilePath default_path,
const FilePath default_filename,
const FileExtension default_extension,
const FileTypes fileTypes,
int  flags,
wxWindow *  parent 

Definition at line 17 of file SelectFile.cpp.

26 return WithDefaultPath(op, default_path, [&](const FilePath &path) {
27 wxString filter;
28 if ( !default_extension.empty() )
29 filter = wxT("*.") + default_extension;
30 return FileSelector(
31 message.Translation(), path, default_filename, filter,
32 FormatWildcard( fileTypes ),
33 flags, parent, wxDefaultCoord, wxDefaultCoord);
34 });
wxString FileSelector(const wxString &title, const wxString &defaultDir, const wxString &defaultFileName, const wxString &defaultExtension, const wxString &filter, int flags, wxWindow *parent, int x, int y)
Definition: FileDialog.cpp:61
wxString FilePath
Definition: Project.h:21
wxString Translation() const
FILES_API wxString FormatWildcard(const FileTypes &fileTypes)
FilePath WithDefaultPath(Operation op, const FilePath &defaultPath, F function)
Definition: FileNames.h:192

References FileSelector(), FileNames::FormatWildcard(), TranslatableString::Translation(), FileNames::WithDefaultPath(), and wxT().

Referenced by AudioUnitEffect::ExportPresets(), BasicEffectUIServices::ExportPresets(), VSTEffect::ExportPresets(), VST3Effect::ExportPresets(), AudioUnitEffect::ImportPresets(), BasicEffectUIServices::ImportPresets(), VST3Effect::ImportPresets(), VSTEffect::ImportPresetsNC(), TimerRecordDialog::OnAutoSavePathButton_Click(), ExportOptionsCLEditor::OnBrowse(), FindFFmpegDialog::OnBrowse(), FindDialog::OnBrowse(), KeyConfigPrefs::OnExport(), ContrastDialog::OnExport(), FrequencyPlotDialog::OnExport(), LabelDialog::OnExport(), anonymous_namespace{FileMenus.cpp}::OnExportLabels(), anonymous_namespace{ExportMIDI.cpp}::OnExportMIDI(), KeyConfigPrefs::OnImport(), LabelDialog::OnImport(), anonymous_namespace{FileMenus.cpp}::OnImportLabels(), anonymous_namespace{ImportMIDI.cpp}::OnImportMIDI(), TagsEditorDialog::OnLoad(), BenchmarkDialog::OnSave(), TagsEditorDialog::OnSave(), anonymous_namespace{LogWindow.cpp}::OnSave(), MacroCommands::ReadMacro(), ProjectFileManager::SaveAs(), ProjectFileManager::SaveCopy(), ShowDiagnostics(), VerifyFilename(), and MacroCommands::WriteMacro().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyFilename()

WX_INIT_API char * VerifyFilename ( const wxString &  s,
bool  input = true 

Protect against Unicode to multi-byte conversion failures on Windows.

Definition at line 45 of file SelectFile.cpp.

47 static wxCharBuffer buf;
48 wxString name = s;
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) {
60 XO(
61"The specified filename could not be converted due to Unicode character use."));
63 ext = ff.GetExt();
64 name = SelectFile(FileNames::Operation::_None,
65 XO("Specify New Filename:"),
66 wxEmptyString,
67 name,
68 ext,
69 { ext.empty()
71 : FileNames::FileType{ {}, { ext } }
72 },
74 wxGetTopLevelParent(NULL));
75 }
76 }
78 mFilename = name.mb_str();
80 return (char *) (const char *) mFilename;
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const TranslatableString name
Definition: Distortion.cpp:76
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
static wxCharBuffer mFilename
Definition: SelectFile.cpp:38
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
FILES_API const FileType AllFiles
Definition: FileNames.h:70

References FileNames::AllFiles, AudacityMessageBox(), TranslatableString::empty(), mFilename, name, SelectFile(), and XO().

Here is the call graph for this function: