本文整理汇总了C++中fs::path::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ path::empty方法的具体用法?C++ path::empty怎么用?C++ path::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs::path
的用法示例。
在下文中一共展示了path::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: state
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;
}
}
示例2: 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();
}
示例3: saveMax
void TextureSequenceOptimizer::saveMax( fs::path path )
{
if ( path == fs::path() ) {
path = app::App::get()->getFolderPath();
app::console() << "SAVE MAX: " << path << std::endl;
}
if( ! path.empty() ){
fs::path jsonPath = path;
jsonPath.append("sequence.json");
JsonTree doc = JsonTree::makeObject();
JsonTree size = JsonTree::makeObject("size");
size.pushBack(JsonTree("width", mOriOutline.getWidth() ));
size.pushBack(JsonTree("height", mOriOutline.getHeight() ));
doc.pushBack(size);
JsonTree sequence = JsonTree::makeArray("sequence");
//go thru each surface
for (int i = 0; i < mSurfaceRefs.size(); i++) {
fs::path tempPath = path;
//only clone the non-transparent area based on the offsets
Surface tempSurf;
JsonTree curImage = JsonTree::makeObject();
if( mTrimMaxAreas[i].calcArea() == 0 ){
app::console() << " Image is completely transparent: " << mFileNames[i] << std::endl;
tempPath.append("transparent.png");
// check if transparent pixel exists
if( !fs::exists(tempPath) ){
// create transparent png if it doesn't exist
tempSurf = mSurfaceRefs[i]->clone( Area(0,0,10,10) );
writeImage( tempPath, tempSurf );
}
// point to transparent image
curImage.pushBack(JsonTree("x", mTrimMaxAreas[i].x1));
curImage.pushBack(JsonTree("y", mTrimMaxAreas[i].y1));
curImage.pushBack(JsonTree("fileName", "transparent.png" ));
}else{
tempSurf = mSurfaceRefs[i]->clone(mTrimMaxAreas[i]);
tempPath.append(toString(mFileNames[i]));
writeImage( tempPath, tempSurf );
curImage.pushBack(JsonTree("x", mTrimMaxAreas[i].x1));
curImage.pushBack(JsonTree("y", mTrimMaxAreas[i].y1));
curImage.pushBack(JsonTree("fileName", mFileNames[i] ));
}
sequence.pushBack(curImage);
//app::console() << "saving: " << tempPath << " "<< mTrimMaxAreas[i] << std::endl;
tempPath.clear();
}
doc.pushBack(sequence);
doc.write( jsonPath, JsonTree::WriteOptions());
//saveJson(path);
}
}
示例4: listAudio
void AudioVisualizerApp::listAudio(const fs::path& directory, vector<fs::path>& list)
{
// clear the list
list.clear();
if(directory.empty() || !fs::is_directory(directory))
return;
// make a list of all audio files in the directory
fs::directory_iterator end_itr;
for( fs::directory_iterator i( directory ); i != end_itr; ++i )
{
// skip if not a file
if( !fs::is_regular_file( i->status() ) ) continue;
// skip if extension does not match
string extension = i->path().extension().string();
extension.erase(0, 1);
if( std::find( mAudioExtensions.begin(), mAudioExtensions.end(), extension ) == mAudioExtensions.end() )
continue;
// file matches
list.push_back(i->path());
}
}
示例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: 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();
}
示例7: playAudio
void AudioVisualizerApp::playAudio( const fs::path& file )
{
FMOD_RESULT err;
// ignore if this is not a file
if( file.empty() || !fs::is_regular_file( file ) )
return;
// if audio is already playing, stop it first
stopAudio();
// stream the audio
err = mFMODSystem->createStream( file.string().c_str(), FMOD_SOFTWARE, NULL, &mFMODSound );
err = mFMODSystem->playSound( FMOD_CHANNEL_FREE, mFMODSound, false, &mFMODChannel );
// we want to be notified of channel events
err = mFMODChannel->setCallback( channelCallback );
// keep track of the audio file
mAudioPath = file;
mIsAudioPlaying = true;
//
console() << "Now playing:" << mAudioPath.filename() << std::endl;
}
示例8: handle_action
bool handle_action(sf::Event event) {
short i;
location the_point;
bool to_return = false;
the_point = {event.mouseButton.x, event.mouseButton.y};
if(file_in_mem.empty())
return false;
for(i = 0; i < 6; i++)
if((the_point.in(pc_area_buttons[i][0])) &&
(univ.party[i].main_status != eMainStatus::ABSENT)) {
do_button_action(0,i);
current_active_pc = i;
redraw_screen();
}
for(i = 0; i < 5; i++)
if((the_point.in(edit_rect[i])) &&
(univ.party[current_active_pc].main_status != eMainStatus::ABSENT)) {
do_button_action(0,i + 10);
switch(i) {
case 0:
display_pc(current_active_pc,10,nullptr);
break;
case 1:
display_pc(current_active_pc,11,nullptr);
break;
case 2:
pick_race_abil(&univ.party[current_active_pc],0);
break;
case 3:
spend_xp(current_active_pc,2,nullptr);
break;
case 4:
edit_xp(&univ.party[current_active_pc]);
break;
}
}
for(i = 0; i < 24; i++)
if((the_point.in(item_string_rects[i][1])) && // drop item
univ.party[current_active_pc].items[i].variety != eItemType::NO_ITEM) {
flash_rect(item_string_rects[i][1]);
univ.party[current_active_pc].take_item(i);
}
for(i = 0; i < 24; i++)
if((the_point.in(item_string_rects[i][2])) && // identify item
univ.party[current_active_pc].items[i].variety != eItemType::NO_ITEM) {
flash_rect(item_string_rects[i][2]);
univ.party[current_active_pc].items[i].ident = true;
}
return to_return;
}
示例9: 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);
}
}
示例10: 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;
}
示例11: loadFile
void ThresholdTestApp::loadFile( const fs::path &path )
{
if( ! path.empty() ) {
mSurface = Surface8u::create( loadImage( path ) );
mGraySurface = Channel( mSurface->getWidth(), mSurface->getHeight() );
mThresholded = Channel( mSurface->getWidth(), mSurface->getHeight() );
ip::grayscale( *mSurface, &mGraySurface );
mThresholdClass = ip::AdaptiveThreshold( &mGraySurface );
}
}
示例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;
}
示例13: GetExecutionPath
fs::path GetExecutionPath()
{
if(g_ExecPath.empty())
{
wchar_t exec_path[MAX_PATH];
DWORD length = GetModuleFileName( NULL, exec_path, MAX_PATH );
PathRemoveFileSpec(exec_path);
g_ExecPath = fs::path(exec_path);
}
return g_ExecPath;
}
示例14: MakeRelative
fs::path Path::MakeRelative(fs::path const& path, fs::path const& base) const {
if (path.empty() || base.empty()) return path;
const auto str = path.string();
if (boost::starts_with(str, "?dummy") || boost::starts_with(str, "dummy-audio:"))
return path;
// Paths on different volumes can't be made relative to each other
if (path.has_root_name() && path.root_name() != base.root_name())
return path.string();
auto path_it = path.begin();
auto ref_it = base.begin();
for (; path_it != path.end() && ref_it != base.end() && *path_it == *ref_it; ++path_it, ++ref_it) ;
agi::fs::path result;
for (; ref_it != base.end(); ++ref_it)
result /= "..";
for (; path_it != path.end(); ++path_it)
result /= *path_it;
return result;
}
示例15: playMusic
void StarsApp::playMusic( const fs::path &path, bool loop )
{
if(mSoundEngine && !path.empty()) {
// stop current music
if(mMusic)
mMusic->stop();
// play music in a very safe way
mMusic = shared_ptr<ISound>( mSoundEngine->play2D( path.string().c_str(), loop, true ), std::mem_fun(&ISound::drop) );
if(mMusic) mMusic->setIsPaused(false);
mMusicPath = path;
mPlayMusic = true;
}
}