本文整理汇总了C++中path::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ path::filename方法的具体用法?C++ path::filename怎么用?C++ path::filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::filename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_acceptable_executable
/// \brief TODOCUMENT
bool options_block::is_acceptable_executable(const path &arg_output_file ///< TODOCUMENT
) {
if (arg_output_file.filename() == ".." || arg_output_file.filename() == ".") {
// cerr << "Here0" << endl;
return false;
}
if (arg_output_file.has_root_directory() || arg_output_file.has_root_name()) {
// cerr << "Here1" << endl;
if (!exists(arg_output_file) && !is_regular_file(arg_output_file)) {
// cerr << "Here2" << endl;
return false;
}
}
return true;
}
示例2: get
LandmarkCollection DefaultNamedLandmarkSource::get(const path& imagePath) {
// Todo: .at throws an out_of_range exception when the element is not found.
// [] inserts a new, empty element if not found. Think about what we want.
// there is also find, which returns an iterator
// and we may want to use an unordered_map because of O(1) access
Logger logger = Loggers->getLogger("imageio");
LandmarkCollection landmarks;
try { // Todo: We should probably change this unreadable try-catch code to find()
landmarks = landmarkCollections.at(imagePath);
} catch (std::out_of_range& e) {
try {
landmarks = landmarkCollections.at(imagePath.filename());
} catch (std::out_of_range& e) {
try {
landmarks = landmarkCollections.at(imagePath.stem());
}
catch (std::out_of_range& e) {
logger.warn("Landmarks for the given image could not be found, returning an empty LandmarkCollection. Is this expected?");
}
}
// we succeeded using the basename
}
return landmarks; // empty if element not found
}
示例3: get_score_classn_values_of_instance_labels
/// \brief TODOCUMENT
///
/// \relates score_classn_value_results_set
void cath::score::write_to_svm_light_data_files(const score_classn_value_results_set &arg_results_set, ///< TODOCUMENT
const path &arg_output_file_stem, ///< TODOCUMENT
const size_t &arg_num_repeats, ///< TODOCUMENT
mt19937 &arg_rng, ///< TODOCUMENT
const double &arg_fraction_train ///< TODOCUMENT
) {
const auto num_instances = get_num_instances ( arg_results_set );
const auto names = get_names ( arg_results_set );
const auto instance_labels = get_instance_labels ( arg_results_set );
const auto scalings = get_value_list_scalings( arg_results_set );
// Get a data structure in which all lists are sorted in the same way
const auto results = transform_build<score_classn_value_vec_vec>(
names,
[&] (const string &x) {
const auto &results_list = arg_results_set.get_score_classn_value_list_of_name( x );
return get_score_classn_values_of_instance_labels( results_list, instance_labels );
}
);
for (const size_t &repeat_ctr : irange( 1_z, arg_num_repeats + 1 ) ) {
const auto repeat_ctr_str = lexical_cast<string>( repeat_ctr );
const path train_file = arg_output_file_stem.parent_path() / ( path( arg_output_file_stem.filename() ).string() + "." + repeat_ctr_str + ".train" );
const path test_file = arg_output_file_stem.parent_path() / ( path( arg_output_file_stem.filename() ).string() + "." + repeat_ctr_str + ".test" );
const size_vec_size_vec_pair split_indices = random_split( arg_rng, num_instances, arg_fraction_train );
write_to_svm_light_data_files_impl( results, scalings, train_file, split_indices.first );
write_to_svm_light_data_files_impl( results, scalings, test_file, split_indices.second );
}
}
示例4: readFile
node_tuple readFile(path currentFile)
{
regex rx("(^|\\s)#include\\s[\"<](.*?)[\">]");
string fileName = currentFile.filename();
transform(fileName.begin(), fileName.end(), fileName.begin(), tolower);
string fileFolder = currentFile.parent_path();
transform(fileFolder.begin(), fileFolder.end(), fileFolder.begin(), tolower);
vector<string> includes;
ifstream sourceFile(currentFile);
stringstream buffer;
buffer << sourceFile.rdbuf();
sourceFile.close();
string sourceFileContent(buffer.str());
sregex_iterator rit(sourceFileContent.begin(), sourceFileContent.end(), rx);
sregex_iterator riend;
smatch res;
string res2;
while (rit != riend) {
res = *rit;
res2 = res[2];
transform(res2.begin(), res2.end(), res2.begin(), tolower);
includes.push_back(res2);
++rit;
}
return make_tuple(fileName, fileFolder, includes);
}
示例5: safe_add_file
void file_manager::safe_add_file(path & file, suffix_array_builder & sa_builder)
{
boost::lock_guard<boost::mutex> locker(lock_);
size_t file_number = files_.size();
std::string file_name = file.filename().string();
files_.push_back(file.string());
sa_builder.add_suffixes(file_name, file_number);
}
示例6:
HUEFile::HUEFile(const path p)
{
//TODO: name = p.filename().string(); for Boost >1.46
name = p.filename().string();
ppath = p.string();
size = file_size(p);
column = 4;
sslimit = 10;
}
示例7: add_resource_dir
static void add_resource_dir(const char* a_class, const path& p)
{
const path xml_file = p / (p.filename().replace_extension(".xml"));
if (!exists(xml_file))
warn() << "Missing resource XML file: " << xml_file;
else
add_resource(a_class, IResourcePtr(new FilesystemResource(p)));
}
示例8: analyse_file
filetype analyse_file(path file){
if(!is_regular_file(file)){
return OTHER;
}
string filename=file.filename().string();
string filename_extension=cut(filename,".").back();
if(in(filename_extension,settings::header_endings)){
return HEADER;
}
else if(in(filename_extension,settings::implementation_endings)){
return IMPL;
}
else return OTHER;
}
示例9: ifs
InquiryProcessor (ThreadPool & _threadPool, std::string _saver): threadPool(_threadPool), saverPath(_saver) {
std::ifstream ifs(saverPath);
std::string textsPath;
getline(ifs, textsPath);
curPath = path(textsPath);
std::string text;
int words = 0;
std::string str;
int counter = 0;
std::vector<double> newText;
while (getline(ifs, str)) {
while(str.find(" ") != std::string::npos) {
text = str.substr(0, str.find(" "));
str = str.substr(str.find(" ") + 1);
newText.push_back(atof(text.c_str()));
}
matrix.push_back(newText);
CPoint kdTreePoint(newText, counter);
counter++;
KDTreeBase.push_back(kdTreePoint);
newText.clear();
}
ifs.close();
directory_iterator end_iter;
try {
if (exists(curPath)) {
if (is_regular_file(curPath)) {
docs = 1;
docNames.push_back(curPath.filename().generic_string());
}
docs = 0;
if (is_directory(curPath)) {
for (directory_iterator p(curPath); p != end_iter; ++p) {
docNames.push_back(p->path().filename().generic_string());
docs++;
}
}
}
} catch (const filesystem_error& ex) {
std::cout << ex.what() << std::endl;
}
for (int i = 0; i < docs; ++i) {
docID.push_back(i);
}
// build для одного, потом выкидываем точку из кдтри бэйз и снова строим вектор рутов
root = BuildKDTree(KDTreeBase);
}
示例10: isCorrectFile
int SortIt::isCorrectFile(path file) {
string fileName = file.filename().string();
// EXISTS = -1
if (!exists(file)) {
return -1;
}
// DUPLICATE = 1
if (boost::starts_with(fileName, DUPLICATE_FILE_TAG)) {
return 1;
}
// FILE OK = 0
return 0;
}
示例11: import_electrum_wallet
uint32_t wallet::import_electrum_wallet(
const path& wallet_dat,
const string& wallet_dat_passphrase,
const string& account_name
)
{ try {
if( NOT is_open() ) FC_CAPTURE_AND_THROW( wallet_closed );
if( NOT is_unlocked() ) FC_CAPTURE_AND_THROW( wallet_locked );
uint32_t count = 0;
auto keys = bitcoin::import_electrum_wallet( wallet_dat, wallet_dat_passphrase );
for( const auto& key : keys )
count += friendly_import_private_key( key, account_name );
start_scan( 0, 1 );
ulog( "Successfully imported ${x} keys from ${file}", ("x",keys.size())("file",wallet_dat.filename()) );
return count;
} FC_CAPTURE_AND_RETHROW( (wallet_dat)(account_name) ) }
示例12: prefixKeyFile
void KeyManager::prefixKeyFile(const path& pKeyFileFName, const std::string& pPrefix) const {
BOOST_LOG_NAMED_SCOPE("KeyManager::renameMallformedKeyFile");
path myNewFName;
try {
if (exists(pKeyFileFName)) {
path myPath = pKeyFileFName.parent_path();
path myFName = pKeyFileFName.filename();
myNewFName = myPath / (path(pPrefix+"-") += myFName);
BOOST_LOG_TRIVIAL(debug)<<"Going to rename "<< pKeyFileFName << " into " << myNewFName << ".";
rename(pKeyFileFName, myNewFName);
} else {
BOOST_LOG_TRIVIAL(debug)<<"File "<< pKeyFileFName << " does not exist.";
}
} catch (const std::exception& myExc) {
BOOST_LOG_TRIVIAL(error)<<"Failed to rename "<< pKeyFileFName << " into " << myNewFName << "because - " << myExc.what();
} catch(...) {
BOOST_LOG_TRIVIAL(error)<<"Failed to rename "<< pKeyFileFName << " into " << myNewFName << ".";
}
}
示例13: set_include
void GenerateStdAfxMaker::set_include( const path& include )
{
for ( size_t i = 0; i < m_includes.size(); ++i )
{
const path& p = m_includes[i].first;
if ( p == include )
{
m_includes[i].second = true;
break;
}
else if ( p.has_parent_path() )
{
if ( p.filename() == include.filename() )
{
m_includes[i].second = true;
break;
}
}
}
}
示例14: compute_epub_hash
size_t inline Epub::compute_epub_hash(const path & _absolute_path)
{
unsigned int size = file_size(_absolute_path);
time_t lmtime = last_write_time(_absolute_path);
string timestring = lexical_cast<std::string>(lmtime);
#ifdef DEBUG
cout << "File Exists" << endl;
cout << "\t Name: " << _absolute_path.filename().string() << endl;
cout << "\t Absolute path: " << _absolute_path.string() << endl;
cout << "\t Size: " << size << endl;
cout << "\t Last Modified: " << timestring << endl;
#endif
//Calculate the hash.
size_t filehash = 0;
hash_combine<string>(filehash, _absolute_path.string());
hash_combine<unsigned int>(filehash, size);
hash_combine<string>(filehash, timestring);
return filehash;
}
示例15: main
int main(int argc, char* argv[])
{
using std::cout;
using std::cerr;
using boost::filesystem::directory_iterator;
using boost::filesystem::ifstream;
using boost::iostreams::filtering_istream;
using boost::iostreams::gzip_decompressor;
const directory_iterator dir_iter;
ptr_vector<genome> genomes(20);
string line;
for (directory_iterator di0(argv[1]); di0 != dir_iter; ++di0)
{
const path genome_path = di0->path();
if (!is_directory(genome_path)) continue;
cout << "Reading " << genome_path.filename() << '\n';
// Parse README
ifstream readme(genome_path / "README");
for (auto i = 0; i < 21; ++i) getline(readme, line);
size_t idx;
while (getline(readme, line) && ((idx = line.find("taxid=", 51)) == string::npos));
const auto taxid = line.substr(idx + 6, line.size() - idx - 7);
readme.close();
// Parse README_CURRENT_BUILD
ifstream build(genome_path / "README_CURRENT_BUILD");
getline(build, line); // ======================================================================
getline(build, line); // Organism: Apis mellifera (honey bee)
const auto organism = line.substr(10, line.size() - 11);
getline(build, line); // NCBI Build Number: 5
const auto ncbiBuild = line.substr(19, line.size() - 20);
getline(build, line); // Version: 1
const auto version = line.substr(9, line.size() - 10);
getline(build, line); // Release date: 29 April 2011
const auto releaseDate = line.substr(14, line.size() - 15);
build.close();
// Construct a genome.
genomes.push_back(new genome(taxid, organism, ncbiBuild, version, releaseDate));
auto& g = genomes.back();
// Sort *.fa.gz
ptr_vector<string> files(20);
for (directory_iterator di(genome_path); di != dir_iter; ++di)
{
const auto p = di->path();
if (p.extension().string() != ".gz") continue;
files.push_back(new string(p.filename().string()));
}
files.sort();
// Parse *.fa.gz in the previously sorted order
g.files.reserve(files.size());
for (const auto& f : files)
{
ifstream in(genome_path / f);
filtering_istream fis;
fis.push(gzip_decompressor());
fis.push(in);
getline(fis, line); // Header line
const auto header = line;
size_t nucleotides = 0;
while (getline(fis, line))
{
if (line.front() == '>')
{
cerr << "Multiple header lines in " << f << '\n';
}
if (line.size() > 70)
{
cerr << "Line longer than 70 characters in " << f << '\n';
}
nucleotides += line.size();
}
g.files.push_back(file_t(f, header, nucleotides));
}
// Compute the overall nucleotides
for (const auto& f : g.files) g.nucleotides += f.nucleotides;
}
// Sort genomes in the descending order of nucleotides
genomes.sort();
// Output genome construction code in javascript
cout << " var genomes = [";
for (auto i = 0; i < genomes.size(); ++i)
{
const auto& g = genomes[i];
if (i) cout << ", ";
cout << "{\n"
<< " taxid: " << g.taxid << ",\n"
<< " name: '" << g.organism << "',\n"
<< " ncbiBuild: " << g.ncbiBuild << ",\n"
<< " version: " << g.version << ",\n"
<< " releaseDate: '" << g.releaseDate << "',\n"
<< " nucleotides: " << g.nucleotides << ",\n"
<< " files: [";
//.........这里部分代码省略.........