本文整理汇总了C++中NameMap::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ NameMap::empty方法的具体用法?C++ NameMap::empty怎么用?C++ NameMap::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameMap
的用法示例。
在下文中一共展示了NameMap::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeFileList
void ArcApp::MakeFileList(NameMap& files)
{
DirTraverser traverser(files, *m_factory);
for (size_t i = 0; i < m_args.size(); ++i) {
#ifndef __WXMSW__
wxString name = m_args[i];
#else
// on Windows expand wildcards
wxString name = wxFindFirstFile(m_args[i], 0);
if (name.empty())
wxLogError(_T("file not found '%s'"), m_args[i].c_str());
while (!name.empty()) {
#endif
// if the name is a directory recursively add all it's contents
if (wxDirExists(name)) {
if (traverser.OnDir(name) == wxDIR_CONTINUE) {
wxDir dir(name);
if (dir.IsOpened())
dir.Traverse(traverser);
}
} else {
traverser.OnFile(name);
}
#ifdef __WXMSW__
name = wxFindNextFile();
}
#endif
}
if (files.empty())
wxLogWarning(_T("nothing to do"));
}
示例2: Add
bool ArcApp::Add()
{
// turn m_args into a list of files, i.e. expand wildcards, recurse
// directories and remove duplicates
NameMap files;
MakeFileList(files);
wxInputStreamPtr in(MakeInputStream());
if (!in.get()) return false;
wxOutputStreamPtr out(MakeOutputStream());
if (!out.get()) return false;
wxArchiveInputStreamPtr arc(m_factory->NewStream(*in));
wxArchiveOutputStreamPtr outarc(m_factory->NewStream(*out));
wxArchiveEntryPtr entry(arc->GetNextEntry());
outarc->CopyArchiveMetaData(*arc);
for (;;) {
bool keep;
NameMap::iterator it;
if (!entry.get()) {
if (files.empty())
break;
it = files.begin();
keep = false;
} else {
it = files.find(entry->GetInternalName());
keep = true;
}
if (it != files.end()) {
wxString name = it->second;
files.erase(it);
if (wxDirExists(name)) {
*m_info << "adding " << name.mb_str() << std::endl;
wxDateTime dt(wxFileModificationTime(name));
if (!outarc->PutNextDirEntry(name, dt))
return false;
keep = false;
} else {
wxFFileInputStream file(name);
if (file.Ok()) {
*m_info << "adding " << name.mb_str() << std::endl;
wxDateTime dt(wxFileModificationTime(name));
if (!outarc->PutNextEntry(name, dt, file.GetSize()) ||
!outarc->Write(file) || !file.Eof())
return false;
keep = false;
}
}
}
if (keep)
if (!outarc->CopyEntry(entry.release(), *arc))
return false;
if (entry.get() || keep)
entry.reset(arc->GetNextEntry());
}
in.reset();
return arc->Eof() && outarc->Close() && out->Close();
}