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


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

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


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

示例1: findExecutableMapcrafterDir

fs::path findExecutableMapcrafterDir(fs::path executable) {
	std::string filename = BOOST_FS_FILENAME(executable);
	if ((filename == "testconfig" || filename == "mapcrafter_markers") &&
			BOOST_FS_FILENAME(executable.parent_path()) == "tools")
		return executable.parent_path().parent_path();
	return executable.parent_path();
}
开发者ID:Fuitad,项目名称:mapcrafter,代码行数:7,代码来源:filesystem.cpp

示例2: WriteDenied

Save::Save(fs::path const& file, bool binary)
: file_name(file)
, tmp_name(unique_path(file.parent_path()/(file.stem().string() + "_tmp_%%%%" + file.extension().string())))
{
	LOG_D("agi/io/save/file") << file;

	fp = agi::make_unique<boost::filesystem::ofstream>(tmp_name, binary ? std::ios::binary : std::ios::out);
	if (!fp->good()) {
		acs::CheckDirWrite(file.parent_path());
		acs::CheckFileWrite(file);
		throw fs::WriteDenied(tmp_name);
	}
}
开发者ID:Aegisub,项目名称:Aegisub,代码行数:13,代码来源:io.cpp

示例3: uniquify

fs::path uniquify(const fs::path &dest)
{
    std::string ext = dest.extension();
    std::string fname = dest.stem();
    fs::path parent = dest.parent_path();

    unsigned number = 1;
    std::string newfname;
    fs::path newdest;

    boost::smatch match;
    if(boost::regex_search(fname, match, uregex)) {
        // Matches are indexes into fname, so don't change it while reading values
        newfname = match[1];
        number = boost::lexical_cast<short>(match[2]);
        fname = newfname;
    }

    do { 
        newfname = fname + "(" + boost::lexical_cast<std::string>(++number) + ")" + ext;
        newdest = parent / newfname;
    } while(fs::exists(newdest));

    return newdest;
}
开发者ID:ahuggel,项目名称:exiv2,代码行数:25,代码来源:organize.cpp

示例4: writeChunk

void disk_cache_man::writeChunk(const fs::path& path, char* buffer,unsigned int size)
{
	if(path.parent_path().parent_path() != 	cachepath) 
	{
		/*Label*/
		if(!fs::exists(path.parent_path().parent_path()))
			fs::create_directory(path.parent_path().parent_path());
	}
	if(!fs::exists(path.parent_path()))
		fs::create_directory(path.parent_path());
	fs::ofstream os(path,ios::out | ios::binary);
	if(!os.good())
		throw runtime_error("Failed to open chunk file for writing in cache manager");
	os.write(buffer,size);
	os.close();
}
开发者ID:Traviis,项目名称:bitcascade-client,代码行数:16,代码来源:disk_cache_man.cpp

示例5: nextAudio

fs::path AudioVisualizerApp::nextAudio( const fs::path& file )
{
	if( file.empty() || !fs::is_regular_file( file ) )
		return fs::path();

	fs::path& directory = file.parent_path();

	// make a list of all audio files in the directory
	vector<fs::path> files;
	listAudio( directory, files );

	// return if there are no audio files in the directory
	if( files.empty() )
		return fs::path();

	// find current audio file
	auto itr = std::find( files.begin(), files.end(), file );

	// if not found, or if it is the last audio file, simply return first audio file
	if( itr == files.end() || *itr == files.back() )
		return files.front();

	// return next file
	return *( ++itr );
}
开发者ID:UIKit0,项目名称:Cinder-Samples,代码行数:25,代码来源:AudioVisualizerApp.cpp

示例6: Copy

void Copy(fs::path const& from, fs::path const& to) {
    acs::CheckFileRead(from);
    CreateDirectory(to.parent_path());
    acs::CheckDirWrite(to.parent_path());

    if (!CopyFile(from.wstring().c_str(), to.wstring().c_str(), false)) {
        switch (GetLastError()) {
        case ERROR_FILE_NOT_FOUND:
            throw FileNotFound(from);
        case ERROR_ACCESS_DENIED:
            throw fs::WriteDenied("Could not overwrite " + to.string());
        default:
            throw fs::WriteDenied("Could not copy: " + util::ErrorString(GetLastError()));
        }
    }
}
开发者ID:rcombs,项目名称:Aegisub,代码行数:16,代码来源:fs.cpp

示例7: resolve

fs::path FileResolver::resolve(const fs::path &path) const {
	/* First, try to resolve in case-sensitive mode */
	for (size_t i=0; i<m_paths.size(); i++) {
		fs::path newPath = m_paths[i] / path;
		if (fs::exists(newPath))
			return newPath;
	}

	#if defined(__LINUX__)
		/* On Linux, also try case-insensitive mode if the above failed */
		fs::path parentPath = path.parent_path();
		std::string filename = boost::to_lower_copy(path.filename().string());

		for (size_t i=0; i<m_paths.size(); i++) {
			fs::path path = m_paths[i] / parentPath;

			if (!fs::is_directory(path))
				continue;

			fs::directory_iterator end, it(path);
			for (; it != end; ++it) {
				if (boost::algorithm::to_lower_copy(it->path().filename().string()) == filename)
					return it->path();
			}
		}
	#endif

	return path;
}
开发者ID:AdrianJohnston,项目名称:ShapeNetRender,代码行数:29,代码来源:fresolver.cpp

示例8: if

fs::path	StarsApp::getNextFile( const fs::path &current )
{
	if( !current.empty() ) {
		bool useNext = false;

		fs::directory_iterator end_itr;
		for( fs::directory_iterator i( current.parent_path() ); i != end_itr; ++i )
		{
			// skip if not a file
			if( !fs::is_regular_file( i->status() ) ) continue;

			if(useNext) {
				// skip if extension does not match
				if( std::find( mMusicExtensions.begin(), mMusicExtensions.end(), i->path().extension() ) == mMusicExtensions.end() )
					continue;

				// file matches, return it
				return i->path();
			}
			else if( *i == current ) {
				useNext = true;
			}
		}
	}

	// failed, return empty path
	return fs::path();
}
开发者ID:rmnzr,项目名称:Cinder-Samples,代码行数:28,代码来源:StarsApp.cpp

示例9: path

fs::path	StarsApp::getPrevFile( const fs::path &current )
{
	if( !current.empty() ) {
		fs::path previous;

		fs::directory_iterator end_itr;
		for( fs::directory_iterator i( current.parent_path() ); i != end_itr; ++i )
		{
			// skip if not a file
			if( !fs::is_regular_file( i->status() ) ) continue;

			if( *i == current ) {
				// do we know what file came before this one?
				if( !previous.empty() )
					return previous;
				else
					break;
			}
			else {
				// skip if extension does not match
				if( std::find( mMusicExtensions.begin(), mMusicExtensions.end(), i->path().extension() ) == mMusicExtensions.end() )
					continue;

				// keep track of this file
				previous = *i;
			}
		}
	}

	// failed, return empty path
	return fs::path();
}
开发者ID:rmnzr,项目名称:Cinder-Samples,代码行数:32,代码来源:StarsApp.cpp

示例10: string

static std::string relativeUrl(fs::path const& from, fs::path const& to)
{
    if (to == from)
        return std::string();
    fs::path r = to.lexically_relative(from.parent_path());
    return r == "." ? std::string() : r.string();
}
开发者ID:daniel-j-h,项目名称:synth,代码行数:7,代码来源:output.cpp

示例11: loadMovieFile

void DXTencoderApp::loadMovieFile( const fs::path &moviePath )
{
    try {
        mMovie = qtime::MovieSurface::create( moviePath );
        
        console() << "Dimensions:" << mMovie->getWidth() << " x " << mMovie->getHeight() << std::endl;
        console() << "Duration:  " << mMovie->getDuration() << " seconds" << std::endl;
        console() << "Frames:    " << mMovie->getNumFrames() << std::endl;
        console() << "Framerate: " << mMovie->getFramerate() << std::endl;
        console() << "Has audio: " << mMovie->hasAudio() << " Has visuals: " << mMovie->hasVisuals() << std::endl;

        mMovie->setLoop( false );
        mMovie->seekToStart();
        //mMovie->play();
        isStarted = true;
        currentFrame = 0;

        
        std::string basePath = moviePath.parent_path().string();
        string newFilename =   moviePath.filename().string();
        strReplace(newFilename, moviePath.extension().string(), ".dxt5");
                                                  
        mDxtCreator.open(basePath + "/" + newFilename);

    }
    catch( ci::Exception &exc ) {
        console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
    }
    
    
    
}
开发者ID:lab101,项目名称:Cinder-DXT,代码行数:32,代码来源:DXT_encoder_GUIApp.cpp

示例12: UnzipLocalIndexFile

void QuarterlyIndexFileRetriever::UnzipLocalIndexFile (const fs::path& local_zip_file_name)
{
	std::ifstream zipped_file(local_zip_file_name.string(), std::ios::in | std::ios::binary);
	Poco::Zip::Decompress expander(zipped_file, local_zip_file_name.parent_path().string(), true);

	expander.decompressAllFiles();

}		// -----  end of method QuarterlyIndexFileRetriever::UnzipLocalIndexFile  -----
开发者ID:cauveri,项目名称:CollectEDGARData,代码行数:8,代码来源:QuarterlyIndexFileRetriever.cpp

示例13: generateModuleFile

void ReflectionParser::generateModuleFile(
    const fs::path &fileHeader,
    const fs::path &fileSource,
    const std::string &sourceHeader,
    const ModuleFile &file
)
{
    // header file
    {
        TemplateData headerData { TemplateData::Type::Object };

        addGlobalTemplateData( headerData );

        headerData[ "moduleFileName" ] = file.name;

        fs::create_directory( fileHeader.parent_path( ) );

        utils::WriteText( 
            fileHeader.string( ), 
            m_moduleFileHeaderTemplate.render( headerData ) 
        );
    }

    // source file
    {
        TemplateData sourceData { TemplateData::Type::Object };

        addGlobalTemplateData( sourceData );

        sourceData[ "moduleFileName" ] = file.name;
        sourceData[ "moduleFileSourceHeader" ] = sourceHeader;
        sourceData[ "moduleFileHeader" ] = fileHeader.string( );

        COMPILE_TYPE_TEMPLATES( sourceData, "class", file.classes );
        COMPILE_TYPE_TEMPLATES( sourceData, "global", file.globals );
        COMPILE_TYPE_TEMPLATES( sourceData, "globalFunction", file.globalFunctions );
        COMPILE_TYPE_TEMPLATES( sourceData, "enum", file.enums );

        fs::create_directory( fileSource.parent_path( ) );

        utils::WriteText( 
            fileSource.string( ),
            m_moduleFileSourceTemplate.render( sourceData ) 
        );
    }
}
开发者ID:fspadoni,项目名称:CPP-Reflection,代码行数:46,代码来源:ReflectionParser.cpp

示例14: initASM_Gaze_Tracker

void ASM_Gaze_Tracker::initASM_Gaze_Tracker(const fs::path & trackermodel, const fs::path & cameraProfile) {
    tracker = load_ft<face_tracker>(trackermodel.string());
    tracker.detector.baseDir = trackermodel.parent_path().string() + fs::path("/").make_preferred().native();
    
    if (cameraProfile.empty() == false) {
        findBestFrontalFaceShapeIn3D();
        readCameraProfile(cameraProfile, cameraMatrix, distCoeffs);
        
    }
}
开发者ID:chrischensy,项目名称:ios_facedetect_1_0,代码行数:10,代码来源:ASMGazeTracker.cpp

示例15:

/*******************************************************************
 * Function Name: GetTrackFilePath
 * Return Type 	: const fs::path
 * Created On	: Mar 5, 2014
 * Created By 	: hrushi
 * Comments		: Get the TrackFile path from the given TrackImage path
 * Arguments	: const fs::path TrackChipPath
 *******************************************************************/
const fs::path TrackXML::GetTrackFilePath( const fs::path fsTrackChipPath)
{
	fs::path fsTrackFldrPath = fsTrackChipPath.parent_path().parent_path();
	string stemname = fsTrackChipPath.stem().string();

	UINT TrackNum, FrameNum;
	string VideoBaseName;

	GetTrkChipNameParts(stemname, TrackNum, FrameNum, VideoBaseName);
	fs::path fsTrackFilePath = fsTrackFldrPath.string() + "/" + VideoBaseName + "_track.xml";

	return fsTrackFilePath;
}
开发者ID:hnkulkarni,项目名称:DetectCarriedObjs-PerfEval,代码行数:21,代码来源:TrackXML.cpp


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