本文整理汇总了C++中poco::Path::getExtension方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::getExtension方法的具体用法?C++ Path::getExtension怎么用?C++ Path::getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::Path
的用法示例。
在下文中一共展示了Path::getExtension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
bool FileExtensionFilter::accept(const Poco::Path& path) const
{
std::string extension = path.getExtension();
std::set<std::string>::iterator iter = _extensions.begin();
while(iter != _extensions.end())
{
bool match = false;
if(_ignoreCase)
{
match = (0 == Poco::UTF8::icompare(extension,*iter));
}
else
{
match = (0 == extension.compare(*iter));
}
if(_acceptMatches && match)
{
return true;
}
++iter;
}
return !_acceptMatches;
}
示例2: setPath
/**
* Confirm that an executable file exists at location.
*/
void TskExecutableModule::setPath(const std::string& location)
{
try
{
// Autogenerate filename extension if needed
Poco::Path tempPath = location;
if (tempPath.getExtension().empty())
{
std::string os = Poco::Environment::osName();
if (os.find("Windows") != std::string::npos ||
os.find("CYGWIN") != std::string::npos ||
os.find("MINGW") != std::string::npos )
{
tempPath.setExtension("exe");
}
// Else we assume the user is on a platform that doesn't use executable extensions.
}
// Call our parent to validate the location.
TskModule::setPath(tempPath.toString());
m_name = Poco::Path(m_modulePath).getBaseName();
// Verify that the file is executable.
Poco::File exeFile(m_modulePath);
if (!exeFile.canExecute())
{
std::wstringstream msg;
msg << L"TskExecutableModule::setPath - File is not executable: "
<< m_modulePath.c_str();
LOGERROR(msg.str());
throw TskException("File is not executable.");
}
}
catch (TskException& tskEx)
{
throw tskEx;
}
catch(std::exception& ex)
{
// Log a message and throw a framework exception.
std::wstringstream msg;
msg << "TskExecutableModule::setPath : " << ex.what();
LOGERROR(msg.str());
throw TskException("Failed to set location: " + m_modulePath);
}
}
示例3: doClone
void CloneMDWorkspace::doClone(const typename MDEventWorkspace<MDE, nd>::sptr ws)
{
std::string outWSName = getPropertyValue("OutputWorkspace");
Progress prog(this, 0.0, 10.0, 100);
BoxController_sptr bc = ws->getBoxController();
if (!bc) throw std::runtime_error("Error with InputWorkspace: no BoxController!");
if (bc->isFileBacked())
{
// Generate a new filename to copy to
prog.report("Copying File");
std::string originalFile = bc->getFilename();
std::string outFilename = getPropertyValue("Filename");
if (outFilename.empty())
{
// Auto-generated name
Poco::Path path = Poco::Path(originalFile).absolute();
std::string newName = path.getBaseName() + "_clone." + path.getExtension();
path.setFileName(newName);
outFilename = path.toString();
}
// Perform the copying
g_log.notice() << "Cloned workspace file being copied to: " << outFilename << std::endl;
Poco::File(originalFile).copyTo(outFilename);
g_log.information() << "File copied successfully." << std::endl;
// Now load it back
IAlgorithm_sptr alg = createSubAlgorithm("LoadMD", 0.5, 1.0, false);
alg->setPropertyValue("Filename", outFilename);
alg->setPropertyValue("FileBackEnd", "1");
alg->setPropertyValue("Memory", "0"); //TODO: How much memory?
alg->setPropertyValue("OutputWorkspace", outWSName);
alg->executeAsSubAlg();
// Set the output workspace to this
IMDEventWorkspace_sptr outWS = alg->getProperty("OutputWorkspace");
this->setProperty("OutputWorkspace", outWS);
}
else
{
// Perform the clone in memory.
boost::shared_ptr<MDEventWorkspace<MDE,nd> > outWS(new MDEventWorkspace<MDE,nd>(*ws));
this->setProperty("OutputWorkspace", boost::dynamic_pointer_cast<IMDEventWorkspace>(outWS) );
}
}
示例4: to
Poco::Path CExtract::to(Poco::Path & downloadedPackage, Poco::Path extractPath)
{
//verification of the extension
std::string extension = downloadedPackage.getExtension();
if ((!boost::iends_with(extension, "zip")) && (!boost::iends_with(extension, "tar.gz")))
throw exception::CNotSupported("Invalid extension package : " + downloadedPackage.toString() + ". Only zip or tar.gz supported. " + extension);
Poco::FileStream inp(downloadedPackage.toString(), std::ios::binary);
// decompress to current working dir
Poco::Zip::Decompress dec(inp, extractPath);
// if an error happens invoke the ZipTest::onDecompressError method
m_unzipError = false;
dec.EError += Poco::Delegate<CExtract, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &CExtract::onDecompressError);
dec.decompressAllFiles();
dec.EError -= Poco::Delegate<CExtract, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &CExtract::onDecompressError);
inp.close();
if (m_unzipError)
{
throw shared::exception::CExtract("Fail to uncompress package : " + m_unzipErrorMessage);
}
return extractPath;
}
示例5: if
std::vector<Poco::Path> getModulePaths(const Poco::Path &path)
{
poco_information(Poco::Logger::get("Pothos.PluginLoader.load"), path.toString());
std::vector<Poco::Path> paths;
const Poco::File file(path);
if (not file.exists()) return paths;
else if (file.isFile() and (path.getExtension() == "@MODULE_[email protected]"))
{
paths.push_back(path);
}
else if (file.isDirectory())
{
std::vector<std::string> files; file.list(files);
for (size_t i = 0; i < files.size(); i++)
{
auto subpaths = getModulePaths(Poco::Path(path, files[i]).absolute());
paths.insert(paths.end(), subpaths.begin(), subpaths.end());
}
}
return paths;
}
示例6: file
Poco::Net::MediaType MediaTypeMap::getMediaTypeForPath(const Poco::Path& path) const
{
Poco::File file(path);
if (file.exists() && file.isDirectory())
{
return Poco::Net::MediaType("inode/directory");
}
else
{
FileExtensionConstIterator iter = _fileExtensionToMediaTypeMap.find(Poco::UTF8::toLower(path.getExtension()));
if (iter != _fileExtensionToMediaTypeMap.end())
{
return (*iter).second;
}
else
{
return _defaultMediaType;
}
}
}