本文整理汇总了C++中path::extension方法的典型用法代码示例。如果您正苦于以下问题:C++ path::extension方法的具体用法?C++ path::extension怎么用?C++ path::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::extension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getImages
void getImages(path p){
try{
vector<string> files;
// Check path exists
if(exists(p)){
if(is_regular_file(p)){
cout << p << " is a regular file, with a size of: " << file_size(p) << endl;
cout << "and it's extension is: " << p.extension().string() << endl;
}else if(is_directory(p)){
int count = 0;
directory_iterator end_itr;
for(directory_iterator itr(p); itr != end_itr; ++itr){
files.push_back(itr -> path().filename().string());
cout << "This is the directory status: " << files[count] << endl;
count ++;
}
}else{
cout << "The path is valid but this is not a regular file." << endl;
}
}else{
cout << "This path is not valid." << endl;
}
}
catch(const filesystem_error& ex){
}
}
示例2: SourceException
Source::Source(LanguagePool *languagePool, const path &sourceFilePath) throw(LanguageException, SourceException)
{
//variable
Language *sourceLanguage = nullptr;
//vérification de l'existence du fichier
if (!exists(sourceFilePath))
{
throw SourceException(tr("Le fichier source \"%0\" n'existe pas.", sourceFilePath.native()));
}
//récupération du langage en fonction de l'extension de la source
sourceLanguage = languagePool->getLanguageWithExtension(sourceFilePath.extension().native());
//parsage de la source
Source(sourceLanguage, sourceFilePath);
}
示例3: main
int main(int argc, char* argv[])
{
if (argc == 1)
{
std::cout << "filtermol2 16_folder 16_id_diff.csv\n";
return 0;
}
const path subset = argv[1];
const path prop = argv[2];
std::cout << "Reading " << prop << std::endl;
vector<string> ids;
ids.reserve(5136507); // Number of molecules in 16_id_diff.csv
string line;
ifstream xls(prop);
// getline(xls, line); // Filter out header line.
while (getline(xls, line))
{
ids.push_back(line);
}
xls.close();
const path mol2_folder = subset / "mol2";
const string delimiter = "@<TRIPOS>MOLECULE";
vector<string> lines; // Each molecule takes up <= 300 lines.
lines.reserve(300);
string id; // e.g. ZINC00000007
const directory_iterator end_dir_iter;
for (directory_iterator dir_iter(subset); dir_iter != end_dir_iter; ++dir_iter)
{
if (!is_regular_file(dir_iter->status())) continue;
const path mol2_file = dir_iter->path();
// const path mol2_file = subset / "16_p0.0.mol2";
if (mol2_file.extension() != ".mol2") continue;
const string slice = mol2_file.stem().string();
std::cout << slice << std::endl;
ifstream in(mol2_file);
while (getline(in, line))
{
if (line == delimiter)
{
if (!lines.empty())
{
if (binary(ids, id.substr(4)))
{
dump(lines, mol2_folder / (id + ".mol2"));
}
lines.clear();
}
lines.push_back(line);
getline(in, id);
lines.push_back(id);
}
else
{
lines.push_back(line);
}
}
in.close();
if (binary(ids, id))
{
dump(lines, mol2_folder / (id + ".mol2"));
}
lines.clear();
}
return 0;
}
示例4: extension
inline std::string extension(const path & p)
{
return p.extension().string();
}
示例5: ConcatDumps
path ConcatDumps(const Config& c, path first, path second) {
auto output_path = c.dump_dir() / boost::filesystem::unique_path(first.stem().native() + "%%%%-%%%%-%%%%-%%%%" + first.extension().c_str());
if (!fs::exists(first)) {
if (!fs::exists(second)) {
auto touch = c.ofstream(output_path);
return output_path;
}
fs::copy_file(second, output_path);
return output_path;
}
fs::copy_file(first, output_path);
if (!fs::exists(second)) {
return output_path;
}
auto previous = c.ifstream(second);
auto append_to = c.ofstream(output_path, std::ios::app);
char buffer[4 << 10];
while(!previous.fail()) {
previous.read(buffer, sizeof(buffer));
append_to.write(buffer, previous.gcount());
}
return output_path;
}
示例6: isDesiredFileType
// Checks for target file parameters
bool Scanner::isDesiredFileType(const path &pathToCheck){
if (!pathToCheck.extension().compare(".jpg"))
if ((MIN_SIZE <= file_size(pathToCheck) && file_size(pathToCheck) <= MAX_SIZE))
return true;
return false;
}