本文整理汇总了C++中boost::filesystem::path::extension方法的典型用法代码示例。如果您正苦于以下问题:C++ path::extension方法的具体用法?C++ path::extension怎么用?C++ path::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::extension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertWaveformData
bool OptionHandler::convertWaveformData(
const boost::filesystem::path& input_filename,
const boost::filesystem::path& output_filename,
const Options& options)
{
WaveformBuffer buffer;
if (!buffer.load(input_filename.c_str())) {
return false;
}
const int bits = options.hasBits() ? options.getBits() : buffer.getBits();
bool success = true;
const boost::filesystem::path output_file_ext = output_filename.extension();
if (output_file_ext == ".json") {
success = buffer.saveAsJson(output_filename.c_str(), bits);
}
else if (output_file_ext == ".txt") {
success = buffer.saveAsText(output_filename.c_str(), bits);
}
return success;
}
示例2: Scan
void Scan(const boost::filesystem::path & path) {
if(args.verbose)
printf("scanning %s\n", path.c_str());
if(!boost::filesystem::exists(path))
throw OpenDirException();
if(!boost::filesystem::is_directory(path))
throw OpenDirException();
// dont parse SVN
if(path.has_extension() && (strcasecmp(path.extension().c_str(), ".svn")==0))
return;
boost::filesystem::directory_iterator end;
for( boost::filesystem::directory_iterator itor = boost::filesystem::directory_iterator( path ); itor != end; itor++)
if(boost::filesystem::is_regular_file( itor->status() ))
if( !itor->path().has_extension() || ((strcasecmp(itor->path().extension().c_str(), ".h")==0) || (strcasecmp(itor->path().extension().c_str(), ".hpp")==0)) )
Add( itor->path().string() );
if( boost::filesystem::is_symlink(path) )
return; // FIXME: better way to deal with gphoto's recursive symlinks?
for( boost::filesystem::directory_iterator itor = boost::filesystem::directory_iterator( path ); itor != end; itor++)
if(boost::filesystem::is_directory( itor->status() ))
Scan( itor->path() );
}
示例3: create_file_backend
void life_cycle_manager::create_file_backend(
boost::filesystem::path file_name, const severity_level severity) {
using namespace boost::log;
if (file_name.extension() != extension)
file_name += extension;
auto backend(boost::make_shared<sinks::text_file_backend>(
keywords::file_name = file_name.string(),
keywords::rotation_size = 200 * 1024 * 1024,
keywords::time_based_rotation =
sinks::file::rotation_at_time_point(12, 0, 0)));
backend->auto_flush(true);
typedef sinks::synchronous_sink<sinks::text_file_backend> sink_type;
auto sink(boost::make_shared<sink_type>(backend));
sink->set_filter(
expressions::attr<severity_level>(severity_attr) >= severity);
sink->set_formatter(expressions::format(record_format)
% expressions::format_date_time<boost::posix_time::ptime>(
time_stamp_attr, time_stamp_format)
% expressions::attr<severity_level>(severity_attr)
% expressions::attr<std::string>(channel_attr)
% expressions::smessage);
boost::log::core::get()->add_sink(sink);
}
示例4: outputFileInfo
void SystemProcessPath::outputFileInfo( const boost::filesystem::path& rPath )
{
std::string br = "";
if(rPath.extension() == ".exe" || rPath.extension() == ".EXE" || rPath.extension() == ".eXE" || rPath.extension() == ".exE" || rPath.extension() == ".eXe" || rPath.extension() == ".Exe")
{
br = rPath.parent_path().string();
br += "\\";
br += rPath.stem().string();
br += rPath.extension().string();
char bh[64];
sprintf_s(bh,"%d",iflag);
stpath = bh;
SystemProcessPath::mmmap.insert(std:: make_pair( SystemProcessPath::stpath,std::string(br)));
}
}
示例5: ParseException
static std::string
loadFile (boost::property_tree::ptree &config,
const boost::filesystem::path &file)
{
boost::filesystem::path extension = file.extension();
boost::filesystem::path extension2 = file.stem().extension();
std::string fileName = file.filename().string();
boost::property_tree::ptree readConfig;
if (extension2.string() == ".conf") {
if (extension.string() == ".json") {
boost::property_tree::read_json (file.string(), readConfig);
} else if (extension.string() == ".info") {
boost::property_tree::read_info (file.string(), readConfig);
} else if (extension.string() == ".ini") {
boost::property_tree::read_ini (file.string(), readConfig);
} else if (extension.string() == ".xml") {
boost::property_tree::read_xml (file.string(), readConfig);
} else {
throw ParseException ("Unknonw file format");
}
} else {
throw ParseException ("Unknonw file format");
}
mergePropertyTrees (config, readConfig);
config.put ("configPath", file.parent_path().string() );
fileName = fileName.substr (0, fileName.size() - extension.string().size() );
fileName = fileName.substr (0, fileName.size() - extension2.string().size() );
return fileName;
}
示例6: try_run_file
void try_run_file(const boost::filesystem::path & cur)
{
if(cur.extension().native().compare(".py"))
{
return;
}
script_file_parser script_file(cur.native());
if(script_file.is_valid())
{
boost::filesystem::path work, out;
create_directories(cur, work, out);
auto parent = cur.parent_path();
auto start = parent.begin();
for(auto p = config::tests.begin(); p != config::tests.end() && *p == *start; ++p, ++start) ;
for(; start != parent.end(); ++start)
{
script_file.add_keyword((*start).native());
}
script_file.add_title(cur.stem().native());
if(config::query->evaluate(script_file))
{
script_scheduler()->schedule_file(cur, work, out);
}
}
}
示例7: parser_filepath
void parser_filepath(const vrString& filePath, vrString& strParentPath, vrString& strFileName, vrString& strStem, vrString& strExtension)
{
const fs::path p1 = filePath;
strParentPath = p1.parent_path().string();
strFileName = p1.filename().string();
strExtension = p1.extension().string();
strStem = p1.stem().string();
}
示例8: pathIsImage
bool pathIsImage(const boost::filesystem::path& path)
{
std::wstring ext = path.extension().wstring();
if (ext == L".jpg" || ext == L".jpeg" || ext == L".png")
return true;
return false;
}
示例9: pathIsMusic
bool pathIsMusic(const boost::filesystem::path& path)
{
std::wstring ext = path.extension().wstring();
if (ext == L".mp3" || ext == L".mp2" || ext == L".mp1" || ext == L".wav" || ext == L".ogg" || ext == L".aiff" || ext == L".flac")
return true;
return false;
}
示例10: write_image
void write_image( Image_<PixelType, ResourceType>const& output_image, boost::filesystem::path const& pathname ){
// select pgm or ppm
if( pathname.extension().native() == ".ppm" ){
// write the image
write_ppm_image( output_image.getResource(), pathname );
}
else if( pathname.extension().native() == ".pgm" ){
// output must be in PixelGray_u8
write_pgm_image( output_image.getResource(), pathname );
}
else{
throw GEO::GeneralException(std::string("Unknown extension (")+pathname.extension().native()+")", std::string(__FILE__), __LINE__);
}
}
示例11:
void
DatasetManager::openFileHelper( boost::filesystem::path aPath, ProgressNotifier::Ptr aProgressNotifier, DatasetID aDatasetId, bool aUseAsCurrent )
{
M4D::Imaging::AImage::Ptr image;
if ( aPath.extension() == ".dcm" || aPath.extension() == ".DCM" ) {
M4D::Dicom::DicomObjSetPtr dicomObjSet = M4D::Dicom::DicomObjSetPtr( new M4D::Dicom::DicomObjSet() );
M4D::Dicom::DcmProvider::LoadSerieThatFileBelongsTo( aPath, aPath.parent_path(), *dicomObjSet, aProgressNotifier );
image = M4D::Dicom::DcmProvider::CreateImageFromDICOM( dicomObjSet );
} else {
image = M4D::Imaging::ImageFactory::LoadDumpedImage( aPath.string() );
}
if (image) {
registerImage( aDatasetId, aPath, image, aUseAsCurrent );
}
if( aProgressNotifier ) {
aProgressNotifier->finished();
}
//mProdconn.PutDataset( image );
}
示例12: extension
void persister::
persist(const sml::model& m, const boost::filesystem::path& p) const {
const std::string extension(p.extension().string());
if (extension != sml_xml_extension) {
BOOST_LOG_SEV(lg, error) << unsupported_extension << extension;
BOOST_THROW_EXCEPTION(
persister_error(unsupported_extension + extension));
}
using dogen::utility::serialization::xml_serialize;
xml_serialize<model>(p, m);
}
示例13:
/**
* Get the tags based on the directory structure.
*
* @param path Path to a file.
* @return A vector of tags.
*/
vector<string> Dir_Parse::get_tags(const fs::path path) {
vector<string> tags;
string str_path = trim_path(path);
// Remove everything we don't want.
boost::trim_if(str_path, boost::is_any_of("/"));
str_path = str_path.substr(0, str_path.find(path.extension().c_str()));
// Split and return.
boost::split(tags, str_path, boost::is_any_of("/"));
return tags;
}
示例14: if
bool
enableBigTIFF(const boost::optional<bool>& wantBig,
storage_size_type pixelSize,
const boost::filesystem::path& filename,
ome::common::Logger& logger)
{
bool enable = false;
// File extension in use.
boost::filesystem::path ext = filename.extension();
// Enable BigTIFF if using a "big" file extension.
bool extBig =
(ext == boost::filesystem::path(".tf2") ||
ext == boost::filesystem::path(".tf8") ||
ext == boost::filesystem::path(".btf"));
// Enable BigTIFF if the pixel size is sufficiently large.
// Multiply by 5% to allow for alignment and TIFF metadata
// overhead.
bool needBig = (pixelSize + pixelSize/20) > storage_size_type(std::numeric_limits<uint32_t>::max());
if ((wantBig && *wantBig) // BigTIFF explicitly requested.
|| extBig // BigTIFF file extension used
|| (!wantBig && needBig)) // BigTIFF unspecified but needed.
{
enable = true;
if (!wantBig && !extBig) // Not set manually
{
boost::format fmt
("Pixel data size is %1%, but TIFF without BigTIFF "
"support enabled has a maximum size of %2%; "
"automatically enabling BigTIFF support to prevent potential failure");
fmt % pixelSize % std::numeric_limits<uint32_t>::max();
BOOST_LOG_SEV(logger, ome::logging::trivial::warning) << fmt.str();
}
}
else if (wantBig && !*wantBig && needBig) // BigTIFF explicitly disabled but needed.
{
boost::format fmt
("Pixel data size is %1%, but TIFF with BigTIFF "
"support disabled has a maximum size of %2%; "
"TIFF writing may fail if the limit is exceeded");
fmt % pixelSize % std::numeric_limits<uint32_t>::max();
BOOST_LOG_SEV(logger, ome::logging::trivial::warning) << fmt.str();
}
return enable;
}
示例15: load_shader
void dynamic_shader_format::load_shader(boost::filesystem::path const& filename) {
std::string extension = filename.extension().string();
bool parse_outputs = false;
if ((extension.compare(".fs") == 0) || (extension.compare(".frag") == 0)) {
obj::shader_base::create_shader< fshd::type::gl_fragment_shader >();
parse_outputs = true;
} else if ((extension.compare(".vs") == 0) || (extension.compare(".vert") == 0)) {
obj::shader_base::create_shader< fshd::type::gl_vertex_shader >();
} else if ((extension.compare(".gs") == 0) || (extension.compare(".geom") == 0)) {
obj::shader_base::create_shader< fshd::type::gl_geometry_shader >();
} else {
__gtulu_error() << "Unknown shader extension " << extension
<< ", please use one of .fs/.frag, .gs/.geom or .vs/.vert.";
}
std::string source = gu::file::get_contents(filename);
obj::shader_base::set_source(source.c_str());
outputs_.clear();
if (parse_outputs) {
boost::regex expression("out\\s+(\\S+)\\s+(\\S+);");
boost::regex array_expression("\\s*(\\S+)\\s*\\[(\\S*)\\]\\s*");
boost::sregex_iterator it(source.begin(), source.end(), expression);
boost::sregex_iterator end;
std::uint32_t id = 0;
while (it != end) {
std::string type_name = it->str(1);
std::string name = it->str(2);
std::uint32_t size = 1;
boost::sregex_iterator name_it(name.begin(), name.end(), array_expression);
boost::sregex_iterator type_it(type_name.begin(), type_name.end(), array_expression);
// We've found a static sized output vector, that's really nice...
if (name_it != end) {
name = name_it->str(1);
size = boost::lexical_cast< std::uint32_t >(name_it->str(2));
// We've just found a dynamic sized output vector, what a wonderful idea...
} else if (type_it != end) {
type_name = type_it->str(1);
size = -1;
}
outputs_.push_back(output_info(id++, name, fout::format::get(type_name), size, -1, -1));
++it;
}
}
} // load_shader