本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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();
}
示例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 );
}
示例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()));
}
}
}
示例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;
}
示例8: if
fs::path StarsApp::getNextFile( const fs::path ¤t )
{
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();
}
示例9: path
fs::path StarsApp::getPrevFile( const fs::path ¤t )
{
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();
}
示例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();
}
示例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;
}
}
示例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 -----
示例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 )
);
}
}
示例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);
}
}
示例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;
}