本文整理汇总了C++中boost::filesystem::path::replace_extension方法的典型用法代码示例。如果您正苦于以下问题:C++ path::replace_extension方法的具体用法?C++ path::replace_extension怎么用?C++ path::replace_extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::replace_extension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostProcess
inline void PostProcess( FS::path sFile)
{
// name temp file
wstring sTmpFile1 = GetTmpFileName();
wstring sTmpFile2 = sTmpFile1 + L".html";
sTmpFile1 += L".mobi";
// rename original file first
FS::rename( sFile, sTmpFile2 );
// get current codepage
auto cp = GetConsoleOutputCP();
// convert to mobi
if (SystemCommand((boost::wformat(g_sCalibre) % sTmpFile2 % sTmpFile1).str()))
{
FS::rename(sTmpFile2, sFile);
FS::rename(sTmpFile1, sFile.replace_extension("mobi"));
BOOST_LOG_TRIVIAL(trace) << "Calibre convert done";
}
else
{
BOOST_LOG_TRIVIAL(error) << "Calibre convert error!";
}
// restore codepage
SetConsoleOutputCP(cp);
}
示例2: SaveToDisk
void handler_Report::SaveToDisk(boost::filesystem::path path){
if ( bFormattedTxt ){
path.replace_extension(".txt");
FormatDataInVector();
blIO::SimpleWriteToFile(path, GeneratDataFromVector() );
blIO::SimpleWriteToFile(path, string("\n") );
}
if (bLog){
path.replace_extension(".log");
for(unsigned i =0; i< uiMaxCols; i++){
blIO::SimpleWriteToFile(path, p_vecstr_Log->at(i) );
blIO::SimpleWriteToFile(path, string("\n") );
}
}
if (bGenXML){
path.replace_extension(".xml");
blIO::SimpleWriteToFile(path, GenerateXMLFromVector() );
}
}
示例3: load_compilation_database
inline args_t load_compilation_database(std::string const &file, fs::path filename)
{
static const std::string source_extensions[] {".c", ".cpp", ".cc"};
static const std::string header_extensions[] {".h", ".hpp", ".hh"};
std::string error;
#if LLVM_VERSION_MAJOR >= 4
auto const database_ptr
(
::clang::tooling::JSONCompilationDatabase::loadFromFile
(
file,
error,
::clang::tooling::JSONCommandLineSyntax::Gnu
)
);
#else
auto const database_ptr
(
::clang::tooling::JSONCompilationDatabase::loadFromFile
(
file,
error
)
);
#endif
if(!database_ptr)
{
core::last_error(error);
return {};
}
std::vector<fs::path> files{filename};
auto const ext(filename.extension());
if(std::find(begin(header_extensions), end(header_extensions), ext) != end(header_extensions))
{
auto path = filename.string();
auto const include_it = path.rfind("include");
if(include_it != std::string::npos)
{
filename = path.replace(include_it, 7, "src");
}
for(auto const &extension : source_extensions)
{
files.emplace_back(filename.replace_extension(extension));
}
}
std::vector<::clang::tooling::CompileCommand> compile_commands;
for(auto const &file : files)
{
compile_commands = database_ptr->getCompileCommands(file.string());
if(!compile_commands.empty())
{
filename = file;
break;
}
}
if(compile_commands.empty())
{ return {}; }
// Skip argv[0] which is the name of the clang executable.
args_t commands((compile_commands[0].CommandLine.begin() + 1), compile_commands[0].CommandLine.end());
// Get rid of the source filename itself.
// NOTE: '-o <output>' and '-c' will be automatically ignored by libclang.
commands.erase(std::remove(commands.begin(), commands.end(), filename), commands.end());
commands.erase(std::remove(commands.begin(), commands.end(), compile_commands[0].Filename), commands.end());
return commands;
}