bool Taskbar::CreateOrUpdate(fs::path const& target_path) { try { if (base::win::version() >= base::win::VERSION_WIN7) { fs::path shortcut_path = base::path::get(base::path::DIR_TEMP) / target_path.filename().replace_extension(L".lnk"); if (!detail::CreateOrUpdateShortcutLink(shortcut_path, target_path)) { throw std::domain_error(("Couldn't create or update shortcut at " + shortcut_path.string()).c_str()); } bool result = detail::TaskbarPinShortcutLink(shortcut_path); fs::remove(shortcut_path); return result; } else { fs::path shortcut_path = base::path::get(base::path::DIR_USER_QUICK_LAUNCH) / target_path.filename().replace_extension(L".lnk"); return detail::CreateOrUpdateShortcutLink(shortcut_path, target_path); } } catch (...) { } return false; }
bool Taskbar::CreateOrUpdate(fs::path const& target_path) { try { if (bee::platform::get_version().ver >= bee::platform::WinVer::Win10) { } else if (bee::platform::get_version().ver >= bee::platform::WinVer::Win7) { fs::path shortcut_path = fs::temp_directory_path() / target_path.filename().replace_extension(L".lnk"); if (!detail::CreateOrUpdateShortcutLink(shortcut_path, target_path)) { throw std::domain_error(("Couldn't create or update shortcut at " + shortcut_path.string()).c_str()); } bool result = detail::TaskbarPinShortcutLink(shortcut_path); fs::remove(shortcut_path); return result; } else { fs::path shortcut_path = detail::quick_launch_path() / target_path.filename().replace_extension(L".lnk"); return detail::CreateOrUpdateShortcutLink(shortcut_path, target_path); } } catch (...) { } return false; }
void ocvOpticalFlowApp::loadMovieFile( const fs::path &moviePath ) { try { // load up the movie, set it to loop, and begin playing mMovie = qtime::MovieSurface( moviePath ); mMovie.setLoop(); mMovie.play(); // create a texture for showing some info about the movie TextLayout infoText; infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) ); infoText.setColor( Color::white() ); infoText.addCenteredLine( moviePath.filename().string() ); infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" ); infoText.addLine( toString( mMovie.getDuration() ) + " seconds" ); infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" ); infoText.addLine( toString( mMovie.getFramerate() ) + " fps" ); infoText.setBorder( 4, 2 ); mInfoTexture = gl::Texture( infoText.render( true ) ); } catch( ... ) { console() << "Unable to load the movie." << std::endl; mMovie.reset(); mInfoTexture.reset(); } mFrameTexture.reset(); }
void trm::Database::createEntry(fs::path path, fs::path trashPath, std::size_t size) { sqlite3_stmt *stmt; std::string objectName = trashPath.filename().string(); const char *cPath = path.remove_filename().c_str(); char sql[] = "INSERT INTO trash (OBJECTNAME, FILESIZE, TRASHPATH, OLDPATH, DELETEDAT) " "VALUES (?, ?, ?, ?, datetime('NOW', 'localtime'));"; dbStatus = sqlite3_prepare(db, sql, -1, &stmt, 0); if (dbStatus != SQLITE_OK) { std::cout << "Database Error: " << errMsg << std::endl; exit(0); } if (sqlite3_bind_text(stmt, 1, objectName.c_str(), -1, SQLITE_STATIC) != SQLITE_OK) std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl; if (sqlite3_bind_int(stmt, 2, static_cast<int>(size)) != SQLITE_OK) std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl; if (sqlite3_bind_text(stmt, 3, trashPath.c_str(), -1, SQLITE_STATIC) != SQLITE_OK) std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl; if (sqlite3_bind_text(stmt, 4, cPath, -1, SQLITE_STATIC)) std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl; if (sqlite3_step(stmt) != SQLITE_DONE) std::cout << "Database Execute Error: " << sqlite3_errmsg(db) << std::endl; }
bool CCompilerDriver::compile(const fs::path &inputPath, const fs::path &outputPath) { string intermediateName = "__" + outputPath.filename().generic_string() + ".cpp"; fs::path intermediatePath = outputPath; intermediatePath.remove_filename(); intermediatePath /= intermediateName; string code; if (!generateCode(inputPath, code)) { return false; } ofstream out; out.open(intermediatePath.generic_string().c_str(), ofstream::out); out.write(code.c_str(), code.size()); out.close(); stringstream command; command << "clang++ " << intermediatePath << " -o " << outputPath; cout << "Executing: " << command.str() << std::endl; system(command.str().c_str()); return true; }
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; }
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; }
void QuickTimeSampleApp::loadMovieFile( const fs::path &moviePath ) { try { // load up the movie, set it to loop, and begin playing mMovie = qtime::MovieGl::create( moviePath ); mMovie->setLoop(); mMovie->play(); // create a texture for showing some info about the movie TextLayout infoText; infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) ); infoText.setColor( Color::white() ); infoText.addCenteredLine( moviePath.filename().string() ); infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" ); infoText.addLine( toString( mMovie->getDuration() ) + " seconds" ); infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" ); infoText.addLine( toString( mMovie->getFramerate() ) + " fps" ); infoText.setBorder( 4, 2 ); mInfoTexture = gl::Texture::create( infoText.render( true ) ); } catch( ci::Exception &exc ) { console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl; mMovie.reset(); mInfoTexture.reset(); } mFrameTexture.reset(); }
void redEyeApp::loadShader() { mError= ""; try { mTimeFrag= fs::last_write_time(mPathFrag); mTimeVert= fs::last_write_time(mPathVert); mNameFrag= mPathFrag.filename().string(); mNameVert= mPathVert.filename().string(); mShader= gl::GlslProg::create(loadFile(mPathVert), loadFile(mPathFrag), NULL); } catch(gl::GlslProgCompileExc &exc) { mError= exc.what(); } catch(...) { mError= "Unable to load shader"; } }
bool can::put(const fs::path& path) { int i = 0; std::ostringstream oss; std::string name; do { oss.str(""); oss << path.filename().string() << " - " << trashinfo::get_current_time() << " - " << i; name = oss.str(); oss << ".trashinfo"; try { trashinfo::create(this->info.as<fs::path>() / oss.str(), path); i = 0; } catch(const std::runtime_error& e) { i++; } } while (i > 0); boost::system::error_code ec; fs::rename(fs::absolute(path), this->files.as<fs::path>() / name, ec); return !ec; }
void QTimeline::load( fs::path filepath ) { clear(); XmlTree doc; try { doc = XmlTree( loadFile( filepath ) ); for( XmlTree::Iter nodeIt = doc.begin("QTimeline/tracks/track"); nodeIt != doc.end(); ++nodeIt ) { string trackName = nodeIt->getAttributeValue<string>("name"); QTimelineTrackRef trackRef = QTimelineTrackRef( new QTimelineTrack( trackName ) ); mTracks.push_back( trackRef ); trackRef->loadXmlNode( *nodeIt ); } mCueManager->loadXmlNode( doc.getChild( "qTimeline/cueList" ) ); } catch ( ... ) { console() << "Error > QTimeline::load(): " << filepath.filename().generic_string() << endl; return; } updateCurrentTime(); }
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; } }
actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_, id_manager& ids) : grammar_() , xinclude_base(xinclude_base_) , templates() , error_count(0) , anchors() , warned_about_breaks(false) , conditional(true) , ids(ids) , imported(false) , macro() , source_mode("c++") , current_file(0) , filename_relative(filein_.filename()) , template_depth(0) , min_section_level(1) , out(out_) , phrase() , values(¤t_file) , to_value(*this) , scoped_cond_phrase(*this) , element(*this) , error(*this) , code(code_action::block, *this) , code_block(code_action::inline_block, *this) , inline_code(code_action::inline_, *this) , paragraph(*this) , list_item(*this) , phrase_end(*this) , raw_char(phrase) , plain_char(phrase, *this) , escape_unicode(phrase, *this) , simple_markup(phrase, *this) , break_(phrase, *this) , do_macro(phrase, *this) , element_id_warning(*this) { // add the predefined macros macro.add ("__DATE__", std::string(quickbook_get_date)) ("__TIME__", std::string(quickbook_get_time)) ("__FILENAME__", detail::path_to_generic(filename_relative)) ; boost::scoped_ptr<quickbook_grammar> g( new quickbook_grammar(*this)); grammar_.swap(g); }
void AssetReloader::reloadAsset( fs::path assetPath ) { // console() << "reload :: " << mKeyList[ assetPath.c_str() ] << endl; string key = ""; key = mKeyList[ assetPath.c_str() ]; if( key != "" ){ console() << "AssetReloader :: reloading asset :: " << assetPath.filename() << endl; load( assetPath.filename(), key ); // fire signal sAssetReloaded(); }else{ console() << "AssetReloader :: can't reload " << assetPath.filename() << endl; } }
/* * 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); }
bool bcp_implementation::is_html_file(const fs::path& p) { static const boost::regex e( ".*\\." "(?:" "html?|css" ")" ); return boost::regex_match(p.filename().generic_string(), e); }
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(); }
bool bcp_implementation::is_source_file(const fs::path& p) { static const boost::regex e( ".*\\." "(?:" "c|cxx|h|hxx|inc|inl|.?pp|yy?" ")", boost::regex::perl | boost::regex::icase ); return boost::regex_match(p.filename().generic_string(), e); }
void ardroneApp::loadMovieFile( const fs::path &moviePath ) { std::string errorMessage = ""; try { // load up the movie, set it to loop, and begin playing mMovie.reset(); mMovie = ffmpeg::MovieGl::create( moviePath ); //mMovie->setLoop(); mMovie->play(); setInfo(moviePath.filename().string()); if (mIsEqualMovieSize) getWindow()->setSize(mMovie->getWidth(), mMovie->getHeight()); } catch( exception& e ) { errorMessage = string("Unable to load the movie. ") + string(e.what()); console() << errorMessage << std::endl; } setInfo(moviePath.filename().string(), errorMessage); mFrameTexture.reset(); }
WorkUnit::WorkUnit(const fs::path & wu_path) : _system_fn(wu_path / "system.xml") , _integrator_fn(wu_path / "integrator.xml") , _state_fn(wu_path / "state.xml") , _codename(wu_path.filename().string()) { auto meta_path = wu_path / "wu.json"; pt::ptree tree; pt::read_json(meta_path.string(), tree); _fullname = tree.get<std::string>("protein.name", "No full name provided"); _description = tree.get<std::string>("protein.description", "No description provided"); _step_chunk = tree.get<int>("step_chunk", 10); }
bool bcp_implementation::is_jam_file(const fs::path& p) { static const boost::regex e( ".*\\." "(?:" "jam|v2" ")" "|" "(Jamfile|Jamroot)\\.?", boost::regex::perl | boost::regex::icase ); return boost::regex_match(p.filename().generic_string(), e); }
SnapShot::SnapShot(const fs::path & name, bool replace) { int num = 0; do { ostringstream oss; oss << name.filename() << '_' << num << ".bmp"; file = name.parent() / oss.str(); num++; } while(!replace && fs::exists(file)); }
Pano( const fs::path& path ) : mDisplayMode{ ivec2(0,0) }, mName( path.filename().string() ) { std::string stem = path.stem().string(); std::transform( stem.begin(), stem.end(), stem.begin(), ::toupper ); switch( stem.back() ) { case 'L': mDisplayMode = ivec2( 0, 0 ); break; case 'R': mDisplayMode = ivec2( 0, 1 ); break; case 'T': mDisplayMode = ivec2( 1, 0 ); break; case 'B': mDisplayMode = ivec2( 1, 1 ); break; default: break; } mLatLong = gl::Texture2d::create( loadImage( path ), gl::Texture2d::Format().wrap( GL_REPEAT ) ); }
static void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename) { if (fs::is_regular_file(wallet_path)) { // Special case for backwards compatibility: if wallet path points to an // existing file, treat it as the path to a BDB data file in a parent // directory that also contains BDB log files. env_directory = wallet_path.parent_path(); database_filename = wallet_path.filename().string(); } else { // Normal case: Interpret wallet path as a directory path containing // data and log files. env_directory = wallet_path; database_filename = "wallet.dat"; } }
// calls must be locked by write-lock void StylesheetManager::onNewStylesheet(const fs::path& stylesheet_path) { // lock the weak_ptr to manager shared_ptr<RequestManager> manager = this->manager.lock(); assert(manager); shared_ptr<Stylesheet> stylesheet; int timeout = config->get<int>(opt::server::parse_timeout); try { std::string new_filename = stylesheet_path.filename().string() + ".mapcss"; fs::path filename(new_filename); stylesheet = Stylesheet::Load(stylesheetFolder / filename, manager->getGeodata(), timeout); } catch(excp::ParseException& e) { shared_ptr<ParserLogger> logger = *boost::get_error_info<excp::InfoParserLogger>(e); // Something went wrong! logger->errorStream() << "Parsing of file \"" << excp::ErrorOut<excp::InfoFileName>(e, stylesheet_path.string()) << "\" failed:"; logger->errorStream() << excp::ErrorOut<excp::InfoWhat>(e, "unknown reason!"); logger->errorStream() << "In line " << excp::ErrorOut<excp::InfoFailureLine>(e) << " column " << excp::ErrorOut<excp::InfoFailureColumn>(e) << ":"; const string* errLine = boost::get_error_info<excp::InfoFailureLineContent>(e); const int* errColumn = boost::get_error_info<excp::InfoFailureColumn>(e); if(errLine) logger->errorStream() << "'" << *errLine << "'"; if(errColumn) logger->errorStream() << string(*errColumn, ' ') << "^-here"; return; } catch(excp::TimeoutException&) { shared_ptr<ParserLogger> logger = boost::make_shared<ParserLogger>(stylesheet_path.string()); logger->errorStream() << "Parsing of stylesheet " << stylesheet_path << " took more then " << timeout << " ms!"; logger->errorStream() << "Parsing canceled!"; logger->errorStream() << "You can configure the timeout via '--parse-timeout'."; return; } parsedStylesheets[stylesheet_path] = stylesheet; // prerenders the upmost tile as well as all higher zoomlevels that are specified in the configuration manager->enqueue(boost::make_shared<MetaIdentifier>(TileIdentifier(0, 0, 0, stylesheet_path.string(), TileIdentifier::PNG))); }
/* In debug mode, this function allows to dump the contributions of the individual sampling strategies to a series of images */ void BDPTWorkResult::dump(const BDPTConfiguration &conf, const fs::path &prefix, const fs::path &stem) const { Float weight = (Float) 1.0f / (Float) conf.sampleCount; for (int k = 1; k<=conf.maxDepth; ++k) { for (int t=0; t<=k+1; ++t) { size_t s = k+1-t; Bitmap *bitmap = const_cast<Bitmap *>(m_debugBlocks[strategyIndex(s, t)]->getBitmap()); ref<Bitmap> ldrBitmap = bitmap->convert(Bitmap::ERGB, Bitmap::EUInt8, -1, weight); fs::path filename = prefix / fs::path(formatString("%s_k%02i_s%02i_t%02i.png", stem.filename().string().c_str(), k, s, t)); ref<FileStream> targetFile = new FileStream(filename, FileStream::ETruncReadWrite); ldrBitmap->write(Bitmap::EPNG, targetFile, 1); } } }
state::state(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_, id_manager& ids) : grammar_() , xinclude_base(xinclude_base_) , templates() , error_count(0) , anchors() , warned_about_breaks(false) , conditional(true) , ids(ids) , callouts() , callout_depth(0) , dependencies() , explicit_list(false) , imported(false) , macro() , source_mode("c++") , source_mode_next() , current_file(0) , filename_relative(filein_.filename()) , template_depth(0) , min_section_level(1) , in_list(false) , in_list_save() , out(out_) , phrase() , values(¤t_file) { // add the predefined macros macro.add ("__DATE__", std::string(quickbook_get_date)) ("__TIME__", std::string(quickbook_get_time)) ("__FILENAME__", std::string()) ; update_filename_macro(); boost::scoped_ptr<quickbook_grammar> g( new quickbook_grammar(*this)); grammar_.swap(g); }
void MovieBasicApp::onReadySignal() { // create a texture for showing some info about the movie TextLayout infoText; infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) ); infoText.setColor( Color::white() ); infoText.addCenteredLine( mMoviePath.filename().string() ); infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" ); infoText.addLine( toString( mMovie->getDuration() ) + " seconds" ); infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" ); infoText.addLine( toString( mMovie->getFramerate() ) + " fps" ); infoText.setBorder( 4, 2 ); mInfoTexture = gl::Texture( infoText.render( true ) ); mMovie->setVolume(1.0f); mMovie->play(); }
bool Desktop::CreateOrUpdate(fs::path const& target_path) { try { fs::path shortcut_path = base::path::get(base::path::DIR_USER_DESKTOP) / target_path.filename().replace_extension(L".lnk"); if (!detail::CreateOrUpdateShortcutLink(shortcut_path, target_path)) { throw std::domain_error(("Couldn't create or update shortcut at " + shortcut_path.string()).c_str()); } return true; } catch (...) { } return false; }
void ShaderToyApp::update() { LoaderData data; // If we are ready for the next shader, take it from the buffer. if( !mShaderNext && mResponses->isNotEmpty() ) { mResponses->popBack( &data ); mPathNext = data.path; mShaderNext = data.shader; // Start the transition. mTransitionTime = getElapsedSeconds(); mTransitionDuration = 2.0; // Update the window title. getWindow()->setTitle( std::string( "ShaderToyApp - Fading from " ) + mPathCurrent.filename().string() + " to " + mPathNext.filename().string() ); } }