• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ fs::path类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: dealStack

/*
 * Deal the stacks into separated files and append them.
 */
void dealStack(const fs::path &outdir, const std::string &prefix,
               const fs::path &imgPath,
               const uint16_t nLayer) {
	TIFF *in, *out;
    static uint16_t iLayer = 0;

    // Suppress the warnings.
	TIFFErrorHandler oldhandler = TIFFSetWarningHandler(NULL);

	// Open the file.
	in = TIFFOpen(imgPath.string().c_str(), "r");
	if (in == NULL) {
		std::cerr << "Unable to read " << imgPath.filename() << std::endl;
		return;
	}

    // Identify the read mode.
	static char mode[3] = { 'x', 'b', 0 };
    // Overwrite on the first run, and append for rest of the page.
    mode[0] = (mode[0] == 'x') ? 'w' : 'a';
    mode[1] = (TIFFIsBigEndian(in)) ? 'b' : 'l';

	// Iterate through the directories.
	int iFile = 0;
	do {
        std::string s = genPath(outdir, prefix, iFile);
		out = TIFFOpen(s.c_str(), mode);
        try {
    		if (out == NULL) {
                throw -1;
    		} else if (!cpTiff(in, out, iLayer, nLayer)) {
                throw -2;
    		}
        } catch (int e) {
            if (e == -1) {
                std::cerr << "Unable to create output file" << std::endl;
            } else if (e == -2) {
                std::cerr << "Unable to copy the layer" << std::endl;
            } else {
                std::cerr << "Unknown error" << std::endl;
            }
            TIFFClose(in);
            TIFFClose(out);
            return;
        }
		TIFFClose(out);
		iFile++;
	} while (TIFFReadDirectory(in));

    // Increment the layer variable for next write.
    iLayer++;

	TIFFClose(in);

    // Restore the warning.
	TIFFSetWarningHandler(oldhandler);
}
开发者ID:liuyenting,项目名称:python-tiff-transpose,代码行数:60,代码来源:tiff.cpp


示例3: parse_document

    static int
    parse_document(
        fs::path const& filein_
      , fs::path const& fileout_
      , fs::path const& deps_out_
      , fs::path const& locations_out_
      , fs::path const& xinclude_base_
      , int indent
      , int linewidth
      , bool pretty_print)
    {
        string_stream buffer;
        id_manager ids;

        int result = 0;

        try {
            quickbook::state state(filein_, xinclude_base_, buffer, ids);
            set_macros(state);

            if (state.error_count == 0) {
                state.add_dependency(filein_);
                state.current_file = load(filein_); // Throws load_error

                parse_file(state);

                if(state.error_count) {
                    detail::outerr()
                        << "Error count: " << state.error_count << ".\n";
                }
            }

            result = state.error_count ? 1 : 0;

            if (!deps_out_.empty())
            {
                fs::ofstream out(deps_out_);
                BOOST_FOREACH(quickbook::state::dependency_list::value_type
                        const& d, state.dependencies)
                {
                    if (d.second) {
                        out << detail::path_to_generic(d.first) << std::endl;
                    }
                }
            }

            if (!locations_out_.empty())
            {
                fs::ofstream out(locations_out_);
                BOOST_FOREACH(quickbook::state::dependency_list::value_type
                        const& d, state.dependencies)
                {
                    out << (d.second ? "+ " : "- ")
                        << detail::path_to_generic(d.first) << std::endl;
                }
            }
开发者ID:cpascal,项目名称:af-cpp,代码行数:56,代码来源:quickbook.cpp


示例4: processModuleFile

// Functor operator, gets invoked on directory traversal
void ModuleLoader::processModuleFile(const fs::path& file)
{
	// Check for the correct extension of the visited file
	if (string::to_lower_copy(file.extension().string()) != MODULE_FILE_EXTENSION) return;

	std::string fullName = file.string();
	rConsole() << "ModuleLoader: Loading module '" << fullName << "'" << std::endl;

	// Create the encapsulator class
	DynamicLibraryPtr library = std::make_shared<DynamicLibrary>(fullName);

	// greebo: Try to find our entry point and invoke it and add the library to the list
	// on success. If the load fails, the shared pointer won't be added and
	// self-destructs at the end of this scope.
	if (library->failed())
	{
		rError() << "WARNING: Failed to load module " << library->getName() << ":" << std::endl;

#ifdef __linux__
		rConsoleError() << dlerror() << std::endl;
#endif
		return;
	}

	// Library was successfully loaded, lookup the symbol
	DynamicLibrary::FunctionPointer funcPtr(
		library->findSymbol(SYMBOL_REGISTER_MODULE)
	);

	if (funcPtr == nullptr)
	{
		// Symbol lookup error
		rError() << "WARNING: Could not find symbol " << SYMBOL_REGISTER_MODULE
			<< " in module " << library->getName() << ":" << std::endl;
		return;
	}

	// Brute-force conversion of the pointer to the desired type
	RegisterModulesFunc regFunc = reinterpret_cast<RegisterModulesFunc>(funcPtr);

	try
	{
		// Call the symbol and pass a reference to the ModuleRegistry
		// This method might throw a ModuleCompatibilityException in its
		// module::performDefaultInitialisation() routine.
		regFunc(ModuleRegistry::Instance());

		// Add the library to the static list (for later reference)
		_dynamicLibraryList.push_back(library);
	}
	catch (module::ModuleCompatibilityException&)
	{
		// Report this error and don't add the module to the _dynamicLibraryList
		rError() << "Compatibility mismatch loading library " << library->getName() << std::endl;
	}
}
开发者ID:codereader,项目名称:DarkRadiant,代码行数:57,代码来源:ModuleLoader.cpp


示例5: remove_hjtremove

int remove_hjtremove(fs::path  path, void* data)
{
	if (strstr(path.string().c_str(),".hjtremove") ||
		strstr(path.string().c_str(),".tmp")){
		boost::system::error_code ec;
		fs::remove(path, ec);
		return ec.value();
	}
	return 0;
}
开发者ID:ghosthjt,项目名称:server_client_common,代码行数:10,代码来源:file_system.cpp


示例6: RenameOver

bool RenameOver(fs::path src, fs::path dest)
{
#ifdef WIN32
    return MoveFileExA(src.string().c_str(), dest.string().c_str(),
                       MOVEFILE_REPLACE_EXISTING) != 0;
#else
    int rc = std::rename(src.string().c_str(), dest.string().c_str());
    return (rc == 0);
#endif /* WIN32 */
}
开发者ID:hungud,项目名称:bitcoin,代码行数:10,代码来源:util.cpp


示例7: 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


示例8: load

void GstVideoServer::load( const fs::path& path )
{
	CI_LOG_I("Load file: " << path.string()  );
	GstPlayer::load(path.string());
	mCurrentFileName = path.filename().string();
    ///> Now that we have loaded we can grab the pipeline..
    mGstPipeline = GstPlayer::getPipeline();
	setupNetworkClock();
    
}
开发者ID:patrickFuerst,项目名称:Cinder-GstVideoSyncPlayer,代码行数:10,代码来源:GstVideoServer.cpp


示例9: file_error

	boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p, file::open_mode m)
	{
		assert(st != 0);
		assert(p.is_complete());
		assert(m == file::in || m == (file::in | file::out));
		boost::mutex::scoped_lock l(m_mutex);
		typedef nth_index<file_set, 0>::type path_view;
		path_view& pt = get<0>(m_files);
		path_view::iterator i = pt.find(p);
		if (i != pt.end())
		{
			lru_file_entry e = *i;
			e.last_use = time_now();

			if (e.key != st)
			{
				// this means that another instance of the storage
				// is using the exact same file.
				throw file_error("torrent uses the same file as another torrent "
					"(" + p.string() + ")");
			}

			e.key = st;
			if ((e.mode & m) != m)
			{
				// close the file before we open it with
				// the new read/write privilages
				i->file_ptr.reset();
				assert(e.file_ptr.unique());
				e.file_ptr.reset();
				e.file_ptr.reset(new file(p, m));
				e.mode = m;
			}
			pt.replace(i, e);
			return e.file_ptr;
		}
		// the file is not in our cache
		if ((int)m_files.size() >= m_size)
		{
			// the file cache is at its maximum size, close
			// the least recently used (lru) file from it
			typedef nth_index<file_set, 1>::type lru_view;
			lru_view& lt = get<1>(m_files);
			lru_view::iterator i = lt.begin();
			// the first entry in this view is the least recently used
			assert(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
			lt.erase(i);
		}
		lru_file_entry e(boost::shared_ptr<file>(new file(p, m)));
		e.mode = m;
		e.key = st;
		e.file_path = p;
		pt.insert(e);
		return e.file_ptr;
	}
开发者ID:codeboost,项目名称:libertv,代码行数:55,代码来源:file_pool.cpp


示例10: Next

bool MDeepFileIteratorImp::Next(
	fs::path&		outFile)
{
	bool result = false;
	
	while (not result and not mStack.empty())
	{
		struct dirent* e = nil;
		
		MInfo& top = mStack.top();
		
		if (top.mDIR != nil)
			THROW_IF_POSIX_ERROR(::readdir_r(top.mDIR, &top.mEntry, &e));
		
		if (e == nil)
		{
			if (top.mDIR != nil)
				closedir(top.mDIR);
			mStack.pop();
		}
		else
		{
			outFile = top.mParent / e->d_name;
			
			struct stat st;
			if (stat(outFile.string().c_str(), &st) < 0 or S_ISLNK(st.st_mode))
				continue;
			
			if (S_ISDIR(st.st_mode))
			{
				if (strcmp(e->d_name, ".") and strcmp(e->d_name, ".."))
				{
					MInfo info;
	
					info.mParent = outFile;
					info.mDIR = opendir(outFile.string().c_str());
					memset(&info.mEntry, 0, sizeof(info.mEntry));
					
					mStack.push(info);
				}
				continue;
			}

			if (mOnlyTEXT and not IsTEXT(outFile))
				continue;

			if (mFilter.length() and not FileNameMatches(mFilter.c_str(), outFile))
				continue;

			result = true;
		}
	}
	
	return result;
}
开发者ID:BackupTheBerlios,项目名称:japi-svn,代码行数:55,代码来源:MFile.cpp


示例11: MakeAbsolute

fs::path Path::MakeAbsolute(fs::path path, std::string const& token) const {
	if (path.empty()) return path;
	int idx = find_token(token.c_str(), token.size());
	if (idx == -1) throw agi::InternalError("Bad token: " + token);

	path.make_preferred();
	const auto str = path.string();
	if (boost::starts_with(str, "?dummy") || boost::starts_with(str, "dummy-audio:"))
		return path;
	return (paths[idx].empty() || path.is_absolute()) ? path : paths[idx]/path;
}
开发者ID:Aegisub,项目名称:Aegisub,代码行数:11,代码来源:path.cpp


示例12:

shared_ptr<ISound> StarsApp::createSound( const fs::path &path )
{
	shared_ptr<ISound>	sound;

	if(mSoundEngine && !path.empty()) {
		// create sound in a very safe way
		sound = shared_ptr<ISound>( mSoundEngine->play3D( path.string().c_str(), vec3df(0,0,0), false, true ), std::mem_fun(&ISound::drop) );
	}

	return sound;
}
开发者ID:rmnzr,项目名称:Cinder-Samples,代码行数:11,代码来源:StarsApp.cpp


示例13: GetFilePath

/*******************************************************************
 * Function Name: GetFullImagePath
 * Return Type 	: const fs::path
 * Created On	: Mar 8, 2014
 * Created By 	: hrushi
 * Comments		: Returns the corresponding full image path for the given track image
 * Arguments	:
 *******************************************************************/
const fs::path TrackXML::GetFullImagePath( UINT FrameNum ) const
{
	const fs::path Parentfldr = GetFilePath().parent_path();
	const string FldrName = Parentfldr.stem().string();

	string ImgStemName = StringOp<UINT>::GetString(FrameNum, '0', 5);

	fs::path FullImgPath = Parentfldr.string() + "/full/" +  FldrName + "." + ImgStemName + ".jpeg";

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


示例14: setReportLocation

bool CrashHandlerImpl::setReportLocation(const fs::path& location) {
	Autolock autoLock(&m_Lock);

	if(location.string().size() >= CrashInfo::MaxFilenameLen) {
		LogError << "Report location path is too long.";
		return false;
	}

	strcpy(m_pCrashInfo->crashReportFolder, location.string().c_str());

	return true;
}
开发者ID:EstrangedGames,项目名称:ArxLibertatis,代码行数:12,代码来源:CrashHandlerImpl.cpp


示例15: test_parent

static void test_parent(const fs::path & in, const std::string & out) {
	
	fs::path p = in.parent();
	arx_assert_msg(p.string() == out, "\"%s\".parent() -> \"%s\" != \"%s\"",
	               in.string().c_str(), p.string().c_str(), out.c_str());
	
	fs::path temp = in;
	temp.up();
	arx_assert_msg(temp.string() == out, "\"%s\".up() ->\"%s\" != \"%s\"",
	               in.string().c_str(), temp.string().c_str(), out.c_str());
	
}
开发者ID:DaveMachine,项目名称:ArxLibertatis,代码行数:12,代码来源:FilePath.cpp


示例16: tryMakeFilePathReal

bool tryMakeFilePathReal(FileForParsing& ffp, vector<fs::path> searchDirs) {
    const fs::path dafExt(".daf");
    const fs::path oExt(".o");

    bool done = false;
    std::string attempt(ffp.m_inputName.string());
    bool tryWithDaf = ffp.m_inputName.extension()!=dafExt;
    while(!done) {
        for(unsigned int i = 0; i < searchDirs.size(); i++) {
            fs::path fullAttempt = searchDirs[i]/fs::path(attempt);
            if(isInputFile(fullAttempt)) {
                ffp.m_inputFile = fullAttempt;
                if(!ffp.m_outputFileSet)
                    ffp.m_outputFile = ffp.m_outputFile/attempt;
                done = true;
                break;
            }
            if(tryWithDaf) {
                fullAttempt = fullAttempt.concat(dafExt.string());
                if(isInputFile(fullAttempt)) {
                    ffp.m_inputFile = fullAttempt;
                    if(!ffp.m_outputFileSet)
                        ffp.m_outputFile = ffp.m_outputFile/attempt;
                    done = true;
                    break;
                }
            }
        }
        if(!done) {
            size_t dotPos = attempt.find('.');
            if(dotPos == std::string::npos) { //We never found the file :'(
                break;
            }
            attempt[dotPos] = '/';
        }
    }

    if(!done) {
        return false;
    }

    //Set output file properly
    if(!ffp.m_outputFileSet) {
        ffp.m_outputFileSet = true;
        if(ffp.m_outputFile.extension()==dafExt) {
            ffp.m_outputFile.replace_extension(oExt);
        } else {
            ffp.m_outputFile+=oExt;
        }
    }
    return true;
}
开发者ID:haved,项目名称:DafCompiler,代码行数:52,代码来源:ArgHandler.cpp


示例17: deleteFile

bool FileService::deleteFile(const fs::path& file)
{
  try
  {
    os_chmod(file.string().c_str(), S_IRUSR|S_IWUSR);
    return fs::remove(file);
  }
  catch (const std::exception ex)
  {
    std::cout << "ERROR: delete file " << file.string() << "; exception: " << ex.what() << std::endl;
    return false;
  }
}
开发者ID:patrikha,项目名称:qdiff,代码行数:13,代码来源:fileservice.cpp


示例18: 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


示例19: GetTrkChipNameParts

/*******************************************************************
 * 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


示例20: loadObject

void AudioObjApp::loadObject( fs::path filepath )
{
    try {
		ObjLoader loader( DataSourcePath::create( filepath.string() ) );
		TriMesh mesh;
		loader.load( &mesh );
		mVbo = gl::VboMesh( mesh );
	}    
	catch( ... ) {
		console() << "cannot load file: " << filepath.generic_string() << endl;
		return;
	}
}
开发者ID:deniskovalev,项目名称:ciResonate,代码行数:13,代码来源:AudioObjApp.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ fsi::vector类代码示例发布时间:2022-05-31
下一篇:
C++ fs::file类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap