本文整理汇总了C++中wxFileName::GetExt方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFileName::GetExt方法的具体用法?C++ wxFileName::GetExt怎么用?C++ wxFileName::GetExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFileName
的用法示例。
在下文中一共展示了wxFileName::GetExt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteImage
//----------------------------------------
void CZFXYPlotFrame::WriteImage(const wxFileName& fileName)
{
vtkWindowToImageFilter* w2i = vtkWindowToImageFilter::New();
CMapImageType mapImageType;
CImageType* imageType = dynamic_cast<CImageType*>(mapImageType[(const char *)(fileName.GetExt())]);
if (imageType == NULL)
{
CException e(CTools::Format("CZFXYPlotFrame::WriteImage - extension:'%s' - dynamic_cast<CImageType*>"
"(CMapImageType::GetInstance()[ext]) returns NULL pointer CMapImageType map seems to "
"contain objects other than those of the class CImageType",
(const char *)(fileName.GetExt())),
BRATHL_LOGIC_ERROR);
CTrace::Tracer("%s", e.what());
throw (e);
}
if (imageType->m_vtkImageWriter == NULL)
{
CException e(CTools::Format("CZFXYPlotFrame::WriteImage - m_vtkImageWriter == NULL - type name:'%s' (extenstion "
"'%s')", (const char *)(imageType->m_name), (const char *)(fileName.GetExt())),
BRATHL_LOGIC_ERROR);
CTrace::Tracer("%s", e.what());
throw (e);
}
try
{
::wxRemoveFile(fileName.GetFullPath());
}
catch (...)
{
//do nothing
}
vtkRenderWindow* renderWindow = m_plotPanel->GetVtkWidget()->GetRenderWindow();
renderWindow->OffScreenRenderingOn();
w2i->SetInput(renderWindow);
imageType->m_vtkImageWriter->SetInput(w2i->GetOutput());
imageType->m_vtkImageWriter->SetFileName(fileName.GetFullPath().c_str());
renderWindow->Render();
imageType->m_vtkImageWriter->Write();
w2i->Delete();
renderWindow->OffScreenRenderingOff();
}
示例2: ClangFormatBuffer
bool CodeFormatter::ClangFormatBuffer(const wxString& content,
const wxFileName& filename,
wxString& formattedOutput,
int& cursorPosition,
int startOffset,
int length)
{
// Write the content into a temporary file
wxFileName fn(clStandardPaths::Get().GetTempDir(), "code-formatter-tmp.cpp");
fn.SetExt(filename.GetExt());
wxFFile fp(fn.GetFullPath(), "w+b");
if(fp.IsOpened()) {
fp.Write(content, wxConvUTF8);
fp.Close();
}
FormatOptions options;
m_mgr->GetConfigTool()->ReadObject(wxT("FormatterOptions"), &options);
bool res = DoClangFormat(fn, formattedOutput, cursorPosition, startOffset, length, options);
{
// Delete the temporary file
wxLogNull nl;
::wxRemoveFile(fn.GetFullPath());
}
return res;
}
示例3: Save
/******************************************************************************
**
* Save the file to the memory buffer. Return the number of bytes used.
* The file name is for informational purposes only, e.g. to decide
* which sub-format to use.
*/
unsigned MCDoc::Save(uint8_t* pBuff, const wxFileName& fileName)
{
unsigned len = 0;
if (fileName.GetExt().CmpNoCase(wxT("ami")) == 0)
len = SaveAmica(pBuff);
else
len = SaveKoala(pBuff);
return len;
}
示例4: wxExGetIconID
int wxExGetIconID(const wxFileName& filename)
{
if (filename.FileExists(filename.GetFullPath()) ||
filename.DirExists(filename.GetFullPath()))
{
if (filename.DirExists(filename.GetFullPath()))
{
return wxFileIconsTable::folder;
}
else if (!filename.GetExt().empty())
{
return wxTheFileIconsTable->GetIconID(filename.GetExt());
}
else
{
return wxFileIconsTable::file;
}
}
else
{
return wxFileIconsTable::computer;
}
}
示例5: CheckFormat
/**
* Check how good data matches our document format. Return a sum of
* MC_FORMAT_*_MATCH.
*/
int MCDoc::CheckFormat(uint8_t* pBuff, unsigned len, const wxFileName& fileName)
{
uint16_t addr;
int match = 0;
if (fileName.GetExt().CmpNoCase(wxT("ami")) == 0 ||
fileName.GetExt().CmpNoCase(wxT("kla")) == 0 ||
fileName.GetExt().CmpNoCase(wxT("koa")) == 0)
{
match += MC_FORMAT_EXTENSION_MATCH;
}
if (len == sizeof(koala_t))
match += MC_FORMAT_SIZE_MATCH;
addr = pBuff[0] + pBuff[1] * 256;
if (addr == KOALA_START_ADDR ||
addr == AMICA_START_ADDR)
{
match += MC_FORMAT_ADDR_MATCH;
}
return match;
}
示例6: DoOpenFile
void DatabaseExplorer::DoOpenFile(const wxFileName& filename)
{
if(filename.GetExt() == wxT("erd")) {
// try to determine used database adapter
IDbAdapter* adapter = NULL;
IDbAdapter::TYPE type = IDbAdapter::atUNKNOWN;
wxSFDiagramManager mgr;
mgr.AcceptShape(wxT("All"));
mgr.SetRootItem(new ErdInfo());
if(mgr.DeserializeFromXml(filename.GetFullPath())) {
ErdInfo* info = wxDynamicCast(mgr.GetRootItem(), ErdInfo);
if(info) type = info->GetAdapterType();
switch(type) {
case IDbAdapter::atSQLITE:
#ifdef DBL_USE_SQLITE
adapter = new SQLiteDbAdapter();
#endif
break;
case IDbAdapter::atMYSQL:
#ifdef DBL_USE_MYSQL
adapter = new MySqlDbAdapter();
#endif
break;
case IDbAdapter::atPOSTGRES:
//#ifdef DBL_USE_POSTGRES
adapter = new PostgreSqlDbAdapter();
//#endif
break;
default:
break;
}
if(adapter) {
ErdPanel* panel = new ErdPanel(m_mgr->GetEditorPaneNotebook(), adapter, NULL);
m_mgr->AddEditorPage(panel, wxString::Format(wxT("ERD [%s]"), filename.GetFullName().c_str()));
panel->LoadERD(filename.GetFullPath());
return;
}
}
}
}
示例7: FindSourceIn
wxFileName ClangPlugin::FindSourceIn(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate)
{
bool extStartsWithCapital = wxIsupper(activeFile.GetExt()[0]);
wxFileName candidateFile;
for (size_t i = 0; i < candidateFilesArray.GetCount(); ++i)
{
wxFileName currentCandidateFile(candidateFilesArray[i]);
if (IsSourceOf(currentCandidateFile, activeFile, isCandidate))
{
bool isUpper = wxIsupper(currentCandidateFile.GetExt()[0]);
if (isUpper == extStartsWithCapital && !isCandidate)
return currentCandidateFile;
else
candidateFile = currentCandidateFile;
}
}
isCandidate = true;
return candidateFile;
}
示例8: GetTypeFromExtension
FileExtManager::FileType FileExtManager::GetTypeFromExtension(const wxFileName& filename)
{
wxCriticalSectionLocker locker(m_CS);
std::unordered_map<wxString, FileExtManager::FileType>::iterator iter = m_map.find(filename.GetExt().Lower());
if(iter == m_map.end()) return TypeOther;
return iter->second;
}
示例9: ConvertLegacyProjectFile
bool ConvertLegacyProjectFile(wxFileName filename)
{
wxTextFile f;
XMLFileWriter xmlFile;
int index = 0;
wxString backupName;
do {
index++;
fflush(stdout);
backupName = filename.GetPath() + wxFILE_SEP_PATH + filename.GetName() +
wxT("_bak") + wxString::Format(wxT("%d"), index) + wxT(".") + filename.GetExt();
} while(::wxFileExists(backupName));
// This will move the original file out of the way, but
// move it back if we exit from this function early.
AutoRollbackRenamer renamer(filename.GetFullPath(), backupName);
if (!renamer.RenameSucceeded())
return false;
f.Open(backupName);
if (!f.IsOpened())
return false;
wxString name = filename.GetFullPath();
try
{
xmlFile.Open(name, wxT("wb"));
}
catch (XMLFileWriterException* pException)
{
delete pException;
return false;
}
renamer.SetNewFile(xmlFile.fp());
try
{
xmlFile.Write(wxT("<?xml version=\"1.0\"?>\n"));
wxString label;
wxString value;
if (f.GetFirstLine() != wxT("AudacityProject"))
return false;
if (f.GetNextLine() != wxT("Version"))
return false;
if (f.GetNextLine() != wxT("0.95"))
return false;
if (f.GetNextLine() != wxT("projName"))
return false;
xmlFile.StartTag(wxT("audacityproject"));
xmlFile.WriteAttr(wxT("projname"), f.GetNextLine());
xmlFile.WriteAttr(wxT("version"), wxT("1.1.0"));
xmlFile.WriteAttr(wxT("audacityversion"),AUDACITY_VERSION_STRING);
label = f.GetNextLine();
while (label != wxT("BeginTracks")) {
xmlFile.WriteAttr(label, f.GetNextLine());
label = f.GetNextLine();
}
label = f.GetNextLine();
while (label != wxT("EndTracks")) {
bool success = ConvertLegacyTrack(&f, xmlFile);
if (!success)
return false;
label = f.GetNextLine();
}
xmlFile.EndTag(wxT("audacityproject"));
xmlFile.Close();
}
catch (XMLFileWriterException* pException)
{
// Error writing XML file (e.g. disk full)
delete pException;
return false;
}
renamer.Finished();
::wxMessageBox(wxString::Format(_("Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'"), backupName.c_str()),
_("Opening Audacity Project"));
return true;
}
示例10: Create
bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
const wxString& defaultDir,
const wxString& defaultFileName,
const wxString& wildCard,
long style, const wxPoint& pos,
const wxSize& sz,
const wxString& name)
{
parent = GetParentForModalDialog(parent, style);
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, sz, name))
{
return false;
}
if (!PreCreation(parent, pos, wxDefaultSize) ||
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
wxDefaultValidator, wxT("filedialog")))
{
wxFAIL_MSG( wxT("wxFileDialog creation failed") );
return false;
}
GtkFileChooserAction gtk_action;
GtkWindow* gtk_parent = NULL;
if (parent)
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
const gchar* ok_btn_stock;
if ( style & wxFD_SAVE )
{
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
ok_btn_stock = GTK_STOCK_SAVE;
}
else
{
gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN;
ok_btn_stock = GTK_STOCK_OPEN;
}
m_widget = gtk_file_chooser_dialog_new(
wxGTK_CONV(m_message),
gtk_parent,
gtk_action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
ok_btn_stock, GTK_RESPONSE_ACCEPT,
NULL);
g_object_ref(m_widget);
GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget);
m_fc.SetWidget(file_chooser);
gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
if ( style & wxFD_MULTIPLE )
gtk_file_chooser_set_select_multiple(file_chooser, true);
// gtk_widget_hide_on_delete is used here to avoid that Gtk automatically
// destroys the dialog when the user press ESC on the dialog: in that case
// a second call to ShowModal() would result in a bunch of Gtk-CRITICAL
// errors...
g_signal_connect(m_widget,
"delete_event",
G_CALLBACK (gtk_widget_hide_on_delete),
this);
// local-only property could be set to false to allow non-local files to be
// loaded. In that case get/set_uri(s) should be used instead of
// get/set_filename(s) everywhere and the GtkFileChooserDialog should
// probably also be created with a backend, e.g. "gnome-vfs", "default", ...
// (gtk_file_chooser_dialog_new_with_backend). Currently local-only is kept
// as the default - true:
// gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
g_signal_connect (m_widget, "response",
G_CALLBACK (gtk_filedialog_response_callback), this);
g_signal_connect (m_widget, "selection-changed",
G_CALLBACK (gtk_filedialog_selchanged_callback), this);
// deal with extensions/filters
SetWildcard(wildCard);
wxString defaultFileNameWithExt = defaultFileName;
if ( !wildCard.empty() && !defaultFileName.empty() &&
!wxFileName(defaultFileName).HasExt() )
{
// append the default extension, if any, to the initial file name: GTK
// won't do it for us by default (unlike e.g. MSW)
const wxFileName fnWC(m_fc.GetCurrentWildCard());
if ( fnWC.HasExt() )
{
// Notice that we shouldn't append the extension if it's a wildcard
// because this is not useful: the user would need to change it to use
// some fixed extension anyhow.
const wxString& ext = fnWC.GetExt();
if ( ext.find_first_of("?*") == wxString::npos )
defaultFileNameWithExt << "." << ext;
}
//.........这里部分代码省略.........
示例11: IsFilenameSupported
bool CSourceDataGenerator::IsFilenameSupported(const wxFileName &fileName)
{
return fileName.GetExt() == "h" || fileName.GetExt() == "c";
}
示例12: ConvertLegacyProjectFile
bool ConvertLegacyProjectFile(wxFileName filename)
{
wxTextFile f;
FILE *outf;
int index = 0;
wxString backupName;
do {
index++;
fflush(stdout);
backupName = filename.GetPath() + wxFILE_SEP_PATH + filename.GetName() +
wxT("_bak") + wxString::Format(wxT("%d"), index) + wxT(".") + filename.GetExt();
} while(::wxFileExists(FILENAME(backupName)));
// This will move the original file out of the way, but
// move it back if we exit from this function early.
AutoRollbackRenamer renamer(filename.GetFullPath(), backupName);
if (!renamer.RenameSucceeded())
return false;
f.Open(FILENAME(backupName));
if (!f.IsOpened())
return false;
wxString name = filename.GetFullPath();
wxFFile out_wxFFile(FILENAME(name).c_str(), wxT("wb"));
if (!out_wxFFile.IsOpened())
return false;
outf = out_wxFFile.fp();
fprintf(outf, "<?xml version='1.0'?>\n");
renamer.SetNewFile(outf);
wxString label;
wxString value;
if (f.GetFirstLine() != wxT("AudacityProject"))
return false;
if (f.GetNextLine() != wxT("Version"))
return false;
if (f.GetNextLine() != wxT("0.95"))
return false;
if (f.GetNextLine() != wxT("projName"))
return false;
fprintf(outf, "<audacityproject projname='%s'",
(const char *)f.GetNextLine().mb_str());
fprintf(outf, " version='1.1.0' audacityversion='%s'",
AUDACITY_VERSION_STRING);
label = f.GetNextLine();
while (label != wxT("BeginTracks")) {
value = f.GetNextLine();
fprintf(outf, " %s='%s'", (const char *)label.mb_str(), (const char *)value.mb_str());
label = f.GetNextLine();
}
fprintf(outf, ">\n");
label = f.GetNextLine();
while (label != wxT("EndTracks")) {
bool success = ConvertLegacyTrack(&f, outf);
if (!success)
return false;
label = f.GetNextLine();
}
fprintf(outf, "</audacityproject>\n");
renamer.Finished();
::wxMessageBox(wxString::Format(_("Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'"), backupName.c_str()),
_("Opening Audacity Project"));
return true;
}
示例13: IsFilenameSupported
bool BinaryDataGenerator::IsFilenameSupported(const wxFileName &fileName)
{
return fileName.GetExt() == "bin";
}