本文整理汇总了C++中bfs::path类的典型用法代码示例。如果您正苦于以下问题:C++ path类的具体用法?C++ path怎么用?C++ path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: path
VideoAsset::VideoAsset(bfs::path videoFile, bfs::path path, bool copy) : path(path) {
try {
name = path.filename().string();
if(!bfs::exists(videoFile)) throw VideoAssetException("video File doesn't exist!");
if(!bfs::exists(path) || !bfs::is_directory(path)) throw VideoAssetException("Destination folder doesn't exist");
if(copy) {
video_path = path;
video_path /= videoFile.filename();
bfs::copy_file(videoFile, video_path, bfs::copy_option::overwrite_if_exists);
} else video_path = videoFile;
isExternal = !copy;
loadPlayerSync();
writeInfoFile();
hasTimetable = false;
hasShotBoundaries = false;
hasHistograms = false;
hasMeans = false;
isReady = false;
} catch (const bfs::filesystem_error& ex) {
(*Tobago.log)(Log::ERROR) << "Error creating video asset " << path.string() << ": " << ex.what();
throw VideoAssetException(ex.what());
}
}
开发者ID:mjunyent,项目名称:Synesthesia,代码行数:27,代码来源:VideoAsset.cpp
示例2: current
void basics::copy_folder(const bfs::path& frompath, const bfs::path& topath)
{
// Check whether the function call is valid
if (!bfs::exists(frompath) || !bfs::is_directory(frompath)) {
std::stringstream err;
err << "Source directory " << frompath.string() << " does not exist or is not a directory.";
throw std::runtime_error(err.str());
}
if(bfs::exists(topath)) {
std::stringstream err;
err << "Destination directory " << topath.string() << " already exists.";
throw std::runtime_error(err.str());
}
// Create the destination directory
if(!bfs::create_directory(topath))
{
std::stringstream err;
err << "Unable to create destination directory " << topath.string();
throw std::runtime_error(err.str());
}
// Iterate through the source directory
for(bfs::directory_iterator file(frompath); file != bfs::directory_iterator(); ++file) {
bfs::path current(file->path());
if(bfs::is_directory(current)) {
// Found directory: Recursion
copy_folder(current, topath / current.filename());
}
else {
// Found file: Copy
bfs::copy_file(current, topath / current.filename());
}
}
}
开发者ID:corentin38,项目名称:pmb,代码行数:35,代码来源:boost_utils.cpp
示例3: GetParentPath
bfs::path GetParentPath(const bfs::path& path) {
#if defined(USE_BOOST_FILESYSTEM_V3) || defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2)
return path.parent_path();
#else
return path.branch_path();
#endif
}
开发者ID:fifengine,项目名称:fifengine,代码行数:7,代码来源:fife_boost_filesystem.cpp
示例4: saveToFile
void World::saveToFile(const bfs::path & path) const
{
Logger::get().debug("Сохранение объектов в файл %1%") % path.string();
json::Object jworld(json::Object::Hash);
// Local rect
{
b2AABB combinedAABB;
combinedAABB.lowerBound.Set( FLT_MAX, FLT_MAX);
combinedAABB.upperBound.Set(-FLT_MAX, -FLT_MAX);
for(const b2Body * b2body = getB2World()->GetBodyList(); b2body; b2body = b2body->GetNext())
{
const Body * body = static_cast<const Body *>(b2body->GetUserData());
if(body->isDynamic())
combinedAABB.Combine(body->getB2AABB());
}
jworld.add("aabb", Rectf::fromB2AABB(combinedAABB).toJson());
}
// Bodies
{
json::Object jentities(json::Object::Array);
for(auto it = getBodyIterator(); it; ++it)
if(it.get()->isDynamic())
jentities.add(it.get()->getEntity()->toJson());
jworld.add("entities", std::move(jentities));
}
std::ofstream file(path.string());
assert(file.good());
file << std::move(jworld.toString(false));
}
开发者ID:theanonym,项目名称:pukan,代码行数:34,代码来源:world.cpp
示例5: find_codedb_path
bfs::path find_codedb_path(const bfs::path& p) {
if (p.empty()) return p;
if (bfs::exists(p / ".codedb")) return p / ".codedb";
return find_codedb_path(p.parent_path());
}
开发者ID:PlastecProfiles,项目名称:CodeDB,代码行数:7,代码来源:codedb.cpp
示例6: openBamFile
void BamReaderPool::openBamFile(const bfs::path& file) {
if (file.empty()) {
throw BamReaderPoolException("No BAM file specified.");
}
std::lock_guard<std::mutex> lock(poolmtx_); // GUARD
closeBamFile_nolock();
if (!open_) {
// try to open all readers
for (BamTools::BamReader& reader : readers_) {
if (!reader.Open(file.c_str())) {
throw BamReaderPoolException(
"Unable to open BAM file " + file.string() + ":\n\t"
+ reader.GetErrorString());
}
}
// try to open index
for (BamTools::BamReader& reader : readers_) {
if (!reader.LocateIndex()) {
throw BamReaderPoolException(
"Unable to open BAM index file " + file.string() + ":\n\t"
+ reader.GetErrorString());
}
}
// all are open, now push them onto the queue
for (BamTools::BamReader& reader : readers_) {
pushReader(reader);
}
file_ = file;
open_ = true;
} else {
throw BamReaderPoolException("Failed to close BAM reader pool.");
}
}
开发者ID:bailey-lab,项目名称:bibseq,代码行数:33,代码来源:BamReaderPool.cpp
示例7: DirectoryCreate
void condor2nav::Download(const std::string &server, const bfs::path &url, const bfs::path &fileName, unsigned timeout /* = 30 */)
{
DirectoryCreate(fileName.parent_path());
bfs::ofstream out{fileName, std::ios_base::out | std::ios_base::binary};
CIStream in{server, url.generic_string(), timeout};
out << in;
}
开发者ID:mpusz,项目名称:Condor2Nav,代码行数:7,代码来源:tools.cpp
示例8: request_new_project_path
bfs::path request_new_project_path( bfs::path default_path )
{
if( default_path.empty() )
default_path = path::DEFAULT_PROJECTS_DIR;
return bfs::path( QFileDialog::getExistingDirectory( nullptr
, QObject::tr("New AOS Designer Project Location")
, QString::fromStdString( default_path.string() )
).toStdString() );
}
开发者ID:Klaim,项目名称:aos-designer,代码行数:10,代码来源:dialogs.cpp
示例9: request_project_path
bfs::path request_project_path( bfs::path default_path )
{
if( default_path.empty() )
default_path = path::DEFAULT_PROJECTS_DIR;
return bfs::path( QFileDialog::getOpenFileName( nullptr
, QObject::tr( "Open AOS Designer Project" )
, QString::fromStdString( default_path.string() )
, QObject::tr( "AOS Designer Project (*.aosp)" )
).toStdString() );
}
开发者ID:Klaim,项目名称:aos-designer,代码行数:11,代码来源:dialogs.cpp
示例10: analyse_image
// Analysis routine
void Crawler::analyse_image(const bfs::path& path)
{
std::ostringstream msg;
msg << "Running image analysis on " << path;
logger->message(msg.str(), traceLevel);
// Construct and segment picture
std::auto_ptr<ImageAnalyst> \
analyst(new ImageAnalyst(bfs::absolute(path.filename()),
analyst_settings));
analyst->segment();
// Get centroids and dump to file if required
if (settings.output) {
std::ostringstream msg;
msg << "Dumping segment centroids to " << settings.outputfile;
logger->message(msg.str(), traceLevel);
// Get segmentation window size
blitz::TinyVector<int, 4> wsize = analyst->get_window_size();
// Open dumpfile as stream, add path, altered path and image and
// window sizes
std::fstream dumpFileStream;
dumpFileStream.open(settings.outputfile.string().c_str(),
std::fstream::out | std::fstream::app);
dumpFileStream << "{'original_file': '" << path.string()
<< "', 'segmented_file': '"
<< path.stem() << "_segments" << bfs::extension(path)
<< "', 'image_size': ("
<< analyst->columns() << ", " << analyst->rows()
<< "), 'window_size': (" << wsize[0] << ", "
<< wsize[1] << ", " << wsize[2] << ", "
<< wsize[3] << "), ";
// Get centroids, push to file
std::vector<Index> centroids;
analyst->get_centroids(centroids);
dumpFileStream << "'centroids': [";
foreach(Index index, centroids)
dumpFileStream << "(" << index[0] << "," << index[1] << "), ";
dumpFileStream << "]}" << std::endl;
// Clean up
dumpFileStream.flush();
dumpFileStream.close();
}
// Exit
logger->message("Done!", traceLevel);
}
开发者ID:jesserobertson,项目名称:blob-extractor,代码行数:52,代码来源:crawler.cpp
示例11: cvCreateMat
ReadCameraParameter::ReadCameraParameter(boost::filesystem::path p){
ifstream camera;
std::string ignore;
double tmp ;
BFS::path txt = p/ "camera.txt";
camera.open(txt.string().c_str());
if( !camera.is_open() ) cout << "Cannot open cameraParameter!" << endl;
else cout << "Success!!!!" << endl;
if( !camera.eof()){
for (int i = 0; i< 5; ++i) getline(camera, ignore, '\n'); // ignore words
camera >> no_frame; // number of frames
cout << "There are " << no_frame << " frames." << endl;
getline(camera, ignore, '\n'); // ignore
for(int s = 0; s < no_frame; s++){ // read camera_para of frames
/* read matrix for K */
CvMat* k = cvCreateMat(3, 3, CV_64FC1);
for(int i = 0; i < 9; i++){
camera >> tmp;
cvmSet(k, (int) (i/3), i%3, tmp);
//cout << i << " " << tmp[i] << endl;
}
K.push_back(k);
/* read matrix for R */
CvMat* r = cvCreateMat(3, 3, CV_64FC1);
for(int i = 0; i < 9; i++){
camera >> tmp;
cvmSet(r, (int) (i/3), i%3, tmp);
//cout << i << " " << tmp[i] << endl;
}
R.push_back(r);
/* read matrix for T */
CvMat* t = cvCreateMat(3, 1, CV_64FC1);
for(int i = 0; i < 3; i++){
camera >> tmp;
cvmSet(t, i%3, 0, tmp);
//cout << i << " " << tmp[i] << endl;
}
T.push_back(t);
for (int i =0; i< 3; ++i)
getline(camera, ignore, '\n'); // ignore
}
}
camera.close();
}
开发者ID:josey822000,项目名称:stereo,代码行数:51,代码来源:ReadCameraParameter.cpp
示例12: BOOST_FOREACH
void RunFolderGenerator::generateRunInfo() const
{
using boost::property_tree::ptree;
ptree pt;
pt.put("RunInfo.<xmlattr>.xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
pt.put("RunInfo.<xmlattr>.xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
pt.put("RunInfo.<xmlattr>.Version", "2");
pt.put("RunInfo.Run.<xmlattr>.Id", runFolder_);
pt.put("RunInfo.Run.<xmlattr>.Number", runInfo_.runNumber);
pt.put("RunInfo.Run.<xmlattr>.TileNameMethod", runInfo_.tileNameMethod);
ptree &run = pt.get_child("RunInfo.Run");
run.put("Flowcell", flowcell_);
run.put("Date", runFolderDate_);
run.put("FlowcellLayout.<xmlattr>.LaneCount", runInfo_.laneCount);
run.put("FlowcellLayout.<xmlattr>.SurfaceCount", runInfo_.surfaceCount);
run.put("FlowcellLayout.<xmlattr>.SwathCount", runInfo_.swathCount);
run.put("FlowcellLayout.<xmlattr>.TileCount", runInfo_.tileCount);
run.put("Reads", "");
ptree &reads = run.get_child("Reads");
int readNum = 1;
BOOST_FOREACH(const eagle::io::ReadDescription &rd, runInfo_.reads)
{
ptree read;
// Attributes for recent RunInfo.xml format
read.put("<xmlattr>.Number", readNum++);
read.put("<xmlattr>.IsIndexedRead", rd.isIndex?"Y":"N");
read.put("<xmlattr>.NumCycles", rd.lastCycle - rd.firstCycle + 1);
// Attributes for older RunInfo.xml format
read.put("<xmlattr>.FirstCycle", rd.firstCycle);
read.put("<xmlattr>.LastCycle", rd.lastCycle);
if (rd.isIndex)
{
read.put("Index", "");
}
reads.add_child("Read", read);
}
const boost::property_tree::xml_writer_settings<string> w(' ', 2);
const bfs::path runInfoPath = runFolderPath_ / "RunInfo.xml";
// DEBUG
std::clog << "Writing RunInfo file " << runInfoPath.string() << std::endl;
write_xml(runInfoPath.string(), pt, std::locale(), w);
}
开发者ID:sequencing,项目名称:EAGLE,代码行数:49,代码来源:RunFolderGenerator.cpp
示例13: GetExtension
std::string GetExtension(const bfs::path& path) {
#if defined(USE_BOOST_FILESYSTEM_V3)
return path.extension().string();
#else
return bfs::extension(path);
#endif
}
开发者ID:fifengine,项目名称:fifengine,代码行数:7,代码来源:fife_boost_filesystem.cpp
示例14: testDefaultTabHandler
void testDefaultTabHandler(const bfs::path& datafile)
{
const char* alphabet = "abcd";
const char* numbers = "1234";
TabReader tr;
VectorTabHandler vth;
tr.setHandler(&vth);
tr.process(datafile.string().c_str());
VectorTabHandler::const_iterator it = vth.begin();
cout << (* (*it).begin()) << endl;
size_t y=0;
for (; it != vth.end(); it++)
{
size_t x=0;
for (vector<string>::const_iterator it2=(*it).begin(); it2!=(*it).end();it2++)
{
const char* value = (*it2).c_str();
unit_assert(value[0] == alphabet[x]);
unit_assert(value[1] == numbers[y]);
x++;
}
cerr << endl;
y++;
}
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:29,代码来源:TabReaderTest.cpp
示例15: create_file
void create_file(const bfs::path& ph, const string& contents)
{
ofstream f(ph.string().c_str());
if (!f)
throw bfs::filesystem_error("create_file", ph, error_code(errno, SYSTEMCATEGORY));
if (!contents.empty()) f << contents;
}
开发者ID:mobiusklein,项目名称:mzR,代码行数:7,代码来源:FilesystemTest.cpp
示例16: persistence_enabled_
DistributedObject::DistributedObject(const bfs::path& file)
: persistence_enabled_(false),
path_(bfs::path()),
file_(!path_.string().empty() && !file.string().empty() ? (path_ / file) : bfs::path()),
timestamp_(0)
{
}
开发者ID:Yale-LANS,项目名称:ALTO,代码行数:7,代码来源:dist_obj.cpp
示例17: testMSIHandler
void testMSIHandler(const bfs::path& datafile)
{
TabReader tr;
MSIHandler mh;
tr.setHandler(&mh);
tr.process(datafile.string().c_str());
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:8,代码来源:TabReaderTest.cpp
示例18:
/**
* @brief Returns file type.
*
* Determinates file type based on its name.
*/
condor2nav::TPathType condor2nav::PathType(const bfs::path &fileName)
{
std::string str{fileName.string()};
if(str.size() > 2 && str[0] == '\\' && str[1] != '\\')
return TPathType::ACTIVE_SYNC;
else
return TPathType::LOCAL;
}
开发者ID:mpusz,项目名称:Condor2Nav,代码行数:13,代码来源:tools.cpp
示例19: itsChangedFlag
/**
* Just initialize fields, does not loads the data.
*
* @param pFilename Where the configuration data will be stored.
*/
YubikoOtpKeyConfig::YubikoOtpKeyConfig(KeyManager& pKeyManager,
const bfs::path& pFilename) :
itsKeyManager(pKeyManager), itsChangedFlag(false), itsFilename(
pFilename) {
BOOST_LOG_NAMED_SCOPE("YubikoOtpKeyConfig::YubikoOtpKeyConfig");
BOOST_LOG_TRIVIAL(debug)<< "Passed filename: " << pFilename.native();
zeroToken();
}
开发者ID:gogoba,项目名称:trihlav,代码行数:13,代码来源:trihlavYubikoOtpKeyConfig.cpp
示例20: expand_pathmask
PWIZ_API_DECL void expand_pathmask(const bfs::path& pathmask,
vector<bfs::path>& matchingPaths)
{
using bfs::path;
#ifdef WIN32
path maskParentPath = pathmask.branch_path();
WIN32_FIND_DATA fdata;
HANDLE srcFile = FindFirstFileEx(pathmask.string().c_str(), FindExInfoStandard, &fdata, FindExSearchNameMatch, NULL, 0);
if (srcFile == INVALID_HANDLE_VALUE)
return; // no matches
do
{
if (strcmp(fdata.cFileName, ".") != 0 &&
strcmp(fdata.cFileName, "..") != 0)
matchingPaths.push_back( maskParentPath / fdata.cFileName );
}
while (FindNextFile(srcFile, &fdata));
FindClose(srcFile);
#else
glob_t globbuf;
int rv = glob(pathmask.string().c_str(), 0, NULL, &globbuf);
if(rv > 0 && rv != GLOB_NOMATCH)
throw runtime_error("FindFilesByMask(): glob() error");
DIR* curDir = opendir(".");
struct stat curEntryData;
for (size_t i=0; i < globbuf.gl_pathc; ++i)
{
stat(globbuf.gl_pathv[i], &curEntryData);
if (S_ISDIR(curEntryData.st_mode) ||
S_ISREG(curEntryData.st_mode) ||
S_ISLNK(curEntryData.st_mode))
matchingPaths.push_back(globbuf.gl_pathv[i]);
}
closedir(curDir);
globfree(&globbuf);
#endif
}
开发者ID:zjjyyang,项目名称:ftdr,代码行数:46,代码来源:Filesystem.cpp
注:本文中的bfs::path类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论