当前位置: 首页>>代码示例>>C++>>正文


C++ path::parent_path方法代码示例

本文整理汇总了C++中path::parent_path方法的典型用法代码示例。如果您正苦于以下问题:C++ path::parent_path方法的具体用法?C++ path::parent_path怎么用?C++ path::parent_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在path的用法示例。


在下文中一共展示了path::parent_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateImage

string HTMLEditor::CreateImage(const IImageCPtr & image, const path & imgPath)
{
    auto imgDirPath = path(IMAGES);
    auto relativePath = imgDirPath / path(image->GetPath()).filename();
    create_directories(imgPath.parent_path() / imgDirPath);
    copy_file(image->GetPath(), imgPath.parent_path() / relativePath, copy_option::overwrite_if_exists);
    return "\t<img src='" + EncodeHtmlStr(relativePath.generic_string()) + "' height=" + to_string(image->GetHeight())+ " width=" + to_string(image->GetWidth()) + ">\n";
}
开发者ID:AniSkyWorker,项目名称:OOD,代码行数:8,代码来源:HTMLEditor.cpp

示例2: Zip

const long Zip ( const BEValueList<std::string> * filenames, const StringAutoPtr archive )
{
    long error = 0;
	
	const path file = filenames->first();
	const path archive_path = *archive;
	
	if ( archive->empty() || exists ( archive_path.parent_path() ) ) {
		
		if ( archive->empty() ) {
			*archive = file.string() + ".zip";
		}
		
		zipFile zip_file;
		const bool dont_overwrite = APPEND_STATUS_CREATE;
		
		zip_file = zipOpen64 ( archive->c_str(), dont_overwrite );
		
		if ( zip_file == NULL ) {
			error = ZIP_ERRNO;
		} else {
			
			for ( size_t i = 0 ; i < filenames->size() ; i++ ) {

				path file_to_archive = filenames->at ( i );
				
				if ( exists ( file_to_archive ) ) {
					error = AddToArchive ( file_to_archive, zip_file, file.parent_path() );
				} else {
					error = kNoSuchFileOrDirectoryError;
					break;
				}
			
			}
		}
		
		// only worry about an error closing the file if there hasn't already been one
		int close_error = zipClose ( zip_file, NULL );
		if ( error == kNoError ) {
			error = close_error;
		}
		
	} else {
		error = kNoSuchFileOrDirectoryError;
	}
	
    return error;
	
} // Zip
开发者ID:coopc,项目名称:BaseElements-Plugin,代码行数:49,代码来源:BEZlib.cpp

示例3: make_pair

/// \brief TODOCUMENT
pair<alignment, superpose_orderer> ssap_scores_file_alignment_acquirer::do_get_alignment_and_orderer(const pdb_list &arg_pdbs ///< TODOCUMENT
                                                                                                     ) const {
	// Parse the SSAP scores file
	const path                     ssap_scores_file = get_ssap_scores_file();
	const pair<str_vec, size_size_pair_doub_map> ssap_scores_data = ssap_scores_file::parse_ssap_scores_file( ssap_scores_file );
	const str_vec                 &names            = ssap_scores_data.first;
	const size_size_pair_doub_map &scores           = ssap_scores_data.second;

	if ( names.size() != arg_pdbs.size() ) {
		BOOST_THROW_EXCEPTION(runtime_error_exception(
			"The number of PDBs is "
			+ ::std::to_string( arg_pdbs.size()         )
			+ ", which doesn't match the "
			+ ::std::to_string( names.size() )
			+ " structures required for combining with the SSAP scores file \""
			+ ssap_scores_file.string()
			+ "\""
		));
	}

	// Make a superpose_orderer from the scores
	const superpose_orderer my_orderer = make_superpose_orderer( scores );

	// Use the superpose_orderer code to get a spanning tree, ordered in descending order of score
	const size_size_pair_vec spanning_tree = get_spanning_tree_ordered_by_desc_score( scores );

//	// TODOCUMENT
	ostringstream stderr;
	const size_size_alignment_tuple_vec spanning_alignments = get_spanning_alignments(
		ssap_scores_file.parent_path(),
		names,
		arg_pdbs,
		spanning_tree,
		stderr
	);

	// TODOCUMENT
	const bool      single_pdb    = ( arg_pdbs.size() == 1 );
	const alignment new_alignment = single_pdb ? make_single_alignment( front( arg_pdbs ).get_num_residues() )
	                                           : build_alignment_from_parts( spanning_alignments, build_protein_list_of_pdb_list( arg_pdbs ) );

	if ( names.size() == 0 ) {
		// Return the results
		return make_pair( new_alignment, my_orderer );
	}

//	BOOST_LOG_TRIVIAL( warning )<< "About to attempt to build protein list using data that's been read from ssap_scores_file (with " << arg_pdbs.size() << " pdbs and " << names.size() << " names)";

	const protein_list proteins_of_pdbs     = build_protein_list_of_pdb_list_and_names( arg_pdbs, names );
	const alignment    scored_new_alignment = score_alignment_copy( residue_scorer(), new_alignment, proteins_of_pdbs );


//	cerr << "Did generate alignment : \n";
//	cerr << horiz_align_outputter( scored_new_alignment ) << endl;
//	write_alignment_as_fasta_alignment( cerr, scored_new_alignment, build_protein_list_of_pdb_list( arg_pdbs ) );
//	cerr << endl;

	// Return the results
	return make_pair( scored_new_alignment, my_orderer );
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:61,代码来源:ssap_scores_file_alignment_acquirer.cpp

示例4: path

CTLProcessParams<CTLPlugin::Scalar> CTLPlugin::getProcessParams( const OfxPointD& renderScale ) const
{
	using namespace boost::filesystem;
	CTLProcessParams<Scalar> params;
	params._inputType = static_cast<EParamChooseInput>( _paramInput->getValue() );
	switch( params._inputType )
	{
		case eParamChooseInputCode:
		{
			params._module = "inputCode";
			params._code = _paramCode->getValue();
			break;
		}
		case eParamChooseInputFile:
		{
//			std::ifstream f( _paramFile->getValue().c_str(), std::ios::in );
//			std::getline( f, params._code, '\0' );
//			split( params._paths, paths, is_any_of(":;"), token_compress_on );
			const path filename = path( _paramFile->getValue() );
			params._module = filename.stem().string();
			params._paths.push_back( filename.parent_path().string() );
			break;
		}
	}
	return params;
}
开发者ID:antdricot,项目名称:TuttleOFX,代码行数:26,代码来源:CTLPlugin.cpp

示例5: 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);
}
开发者ID:andzhik,项目名称:IncludeReader,代码行数:32,代码来源:IncludeReader.cpp

示例6: 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 );
	}
}
开发者ID:sillitoe,项目名称:cath-tools,代码行数:35,代码来源:score_classn_value_results_set.cpp

示例7: __create_directories

bool __create_directories(const path& p, std::error_code *ec)
{
    std::error_code m_ec;
    auto const st = detail::posix_stat(p, &m_ec);
    if (!status_known(st)) {
        set_or_throw(m_ec, ec, "create_directories", p);
        return false;
    }
    else if (is_directory(st)) {
        if (ec) ec->clear();
        return false;
    }
    else if (exists(st)) {
        set_or_throw(make_error_code(errc::file_exists),
                     ec, "create_directories", p);
        return false;
    }

    const path parent = p.parent_path();
    if (!parent.empty()) {
        const file_status parent_st = status(parent, m_ec);
        if (not status_known(parent_st)) {
            set_or_throw(m_ec, ec, "create_directories", p);
            return false;
        }
        if (not exists(parent_st)) {
            __create_directories(parent, ec);
            if (ec && *ec) { return false; }
        }
    }
    return __create_directory(p, ec);
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:32,代码来源:operations.cpp

示例8: is_acceptable_output_file

/// \brief TODOCUMENT
bool options_block::is_acceptable_output_file(const path &arg_output_file ///< TODOCUMENT
                                              ) {
	if (exists(arg_output_file) && !is_regular_file(arg_output_file)) {
		return false;
	}
	if (arg_output_file.has_parent_path() && !is_directory(arg_output_file.parent_path())) {
		return false;
	}
	return true;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:11,代码来源:options_block.cpp

示例9: filestream

vector<path> get_includes(path file, set<path>& touched_files){
	debug(3,"reading dependencies for „"+file.string()+"“");
	if( touched_files.count(file) ){
		debug(4, "\tfile is already known");
		return vector<path>();
	}
	else{
		touched_files.insert(file);
	}
	vector<path> includes;
	string line;
	ifstream filestream(file.c_str());
	path file_dir=file.parent_path();
	while(getline(filestream,line)){
		line = strip(line);
		if(!line.empty() && line[0]=='#' && strip(line.substr(1)).find("include")==0){
			line.erase(0,sizeof("#include"));
			line = strip(line);
			if(line[0]!='"') continue;
			line.erase(0,1);
			size_t pos;
			if((pos=line.find('"'))==string::npos) continue;
			line.erase(pos);
			
			path include=clean_path(file_dir/path(line));
			if(std::find(settings::header_files.begin(),
			             settings::header_files.end(),include)
			   == settings::header_files.end()
			){
				if(std::find(
					settings::implementation_files.begin(),
					settings::implementation_files.end(),
					include)
				   == settings::implementation_files.end()
				){
					continue;
				}
			}
			includes.push_back(include);
		}
	}
	vector<path> secondary_includes, tmp;
	for(auto i:includes){
		tmp=get_includes(i, touched_files);
		secondary_includes.insert(secondary_includes.end(),
		                          tmp.begin(),tmp.end());
	}
	includes.insert(includes.end(),secondary_includes.begin(),
	                secondary_includes.end());
	return includes;
}
开发者ID:Florianjw,项目名称:Makefilecreator,代码行数:51,代码来源:depcheck.cpp

示例10: create_directories

inline bool create_directories(const path & p) {
	
	if(p.empty()) {
		return true;
	}
	
	path parent = p.parent_path();
	if(!exists(parent)) {
		if(!create_directories(parent)) {
			return false;
		}
	}
	
	return create_directory(p);
}
开发者ID:a-detiste,项目名称:innoextract,代码行数:15,代码来源:boostfs_compat.hpp

示例11: Touch

void Touch(path const& file) {
    CreateDirectory(file.parent_path());

    SYSTEMTIME st;
    FILETIME ft;
    GetSystemTime(&st);
    if(!SystemTimeToFileTime(&st, &ft))
        throw EnvironmentError("SystemTimeToFileTime failed with error: " + util::ErrorString(GetLastError()));

    scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)>
    h(CreateFile(file.c_str(), GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr), CloseHandle);
    // error handling etc.
    if (!SetFileTime(h, nullptr, nullptr, &ft))
        throw EnvironmentError("SetFileTime failed with error: " + util::ErrorString(GetLastError()));
}
开发者ID:rcombs,项目名称:Aegisub,代码行数:15,代码来源:fs.cpp

示例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 << ".";
	}
}
开发者ID:gogoba,项目名称:trihlav,代码行数:19,代码来源:trihlavKeyManager.cpp

示例13: main

int main()
{
  using namespace fs;
  for (auto const & TC : TestCases) {
    path const p_orig(TC.value);
    path p(p_orig);
    assert(p == TC.value);
    path& Ref = (p.remove_filename());
    assert(p == TC.expect);
    assert(&Ref == &p);
    {
      const path parentp = p_orig.parent_path();
      if (parentp == p_orig.root_name()) {

        assert(p.empty());
      } else {
        assert(p == parentp);
      }
    }
  }
}
开发者ID:Aj0Ay,项目名称:libcxx,代码行数:21,代码来源:remove_filename.pass.cpp

示例14: findSubDirectory_internal

static UString findSubDirectory_internal(const UString &directory, const UString &subDirectory,
		bool caseInsensitive) {

	try {
		// Special case: . is the same, current directory
		if (subDirectory == UString("."))
			return directory;

		const path dirPath(directory.c_str());

		// Special case: .. is the parent directory
		if (subDirectory == UString("..")) {
			path parent = dirPath.parent_path();
			if (parent == dirPath)
				return "";

			return parent.generic_string();
		}

		// Iterator over the directory's contents
		directory_iterator itEnd;
		for (directory_iterator itDir(dirPath); itDir != itEnd; ++itDir) {
			if (is_directory(itDir->status())) {
				// It's a directory. Check if it's the one we're looking for

				if (caseInsensitive) {
					if (iequals(itDir->path().filename().string(), subDirectory.c_str()))
						return itDir->path().generic_string();
				} else {
					if (equals(itDir->path().filename().string(), subDirectory.c_str()))
						return itDir->path().generic_string();
				}
			}
		}
	} catch (...) {
	}

	return "";
}
开发者ID:berenm,项目名称:xoreos,代码行数:39,代码来源:filepath.cpp

示例15: Save

void HTMLEditor::Save(const path & path)
{
    if (path.empty())
    {
        throw runtime_error("Path cannot be empty!");
    }

    if (path.has_parent_path())
    {
        create_directories(path.parent_path());
    }

    std::ofstream file(path.generic_string());

    if (!file.is_open())
    {
        throw runtime_error("Invalid path specified" + path.generic_string());
    }

    file << "<!DOCTYPE html>\n<html>\n<head>\n\t<title>" << EncodeHtmlStr(m_document.GetTitle()) << "</title>\n</head>\n"
        << "<body>\n" << CreateBody(path) << "</body>\n</html>";
    file.close();
}
开发者ID:AniSkyWorker,项目名称:OOD,代码行数:23,代码来源:HTMLEditor.cpp


注:本文中的path::parent_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。