void Preferences::init() { QDir dir(QFileInfo(fileName()).absoluteDir()); TESTMODE = TESTMODEDEFAULT; UPDATECHECKTIMEOUTSECS = UPDATECHECKTIMEOUTSECSDEFAULT; HOSTLISTURL = HOSTLISTURLDEFAULT; PINGSPERHOST = PINGSPERHOSTDEFAULT; PINGTHREADS = PINGTHREADSDEFAULT; DOWNLOADTESTSECS = DOWNLOADTESTSECSDEFAULT; PINGTIMEOUTSECS = PINGTIMEOUTSECSDEFAULT; if(!dir.exists()) // If necessary, create subdir for the program's INI files { emit message(trUtf8("Creating program preferences directory") + ' ' + QDir::toNativeSeparators(dir.path())); dir.mkpath(dir.path()); } if(_exists() || _restoreEmbeddedOk()) // First, check for a local existing preferences file. If not found, then try to restore one from the library's embedded resources. If either method succeeds, try to load the preferences file { if(!_loadOk()) { emit message(trUtf8("Error parsing %1. Not a valid preferences file").arg(QDir::toNativeSeparators(fileName()))); } return; } // At this point, no method gave a readable preferences file. The application should use the default global values provided by the library as starting values for preferences }
GridFSChunk GridFile::getChunk( int n ) { _exists(); BSONObjBuilder b; b.appendAs( _obj["_id"] , "files_id" ); b.append( "n" , n ); BSONObj o = _grid->_client.findOne( _grid->_chunksNS.c_str() , b.obj() ); uassert( 10014 , "chunk is empty!" , ! o.isEmpty() ); return GridFSChunk(o); }
gridfs_offset GridFile::write( ostream & out ) { _exists(); const int num = getNumChunks(); for ( int i=0; i<num; i++ ) { GridFSChunk c = getChunk( i ); int len; const char * data = c.data( len ); out.write( data , len ); } return getContentLength(); }
CachedImage::CachedImage(CacheManager* parent, QString url) : QObject(parent) , _man(parent) , _headReply(nullptr) , _reply(nullptr) , _format(UnknownFormat) , _url(url) , _kbytesReceived(0) , _kbytesTotal(0) , _available(false) { Q_ASSERT(_man); Q_TEST(connect(&_saveWatcher, &QFutureWatcher<void>::finished, this, &CachedImage::downloadingChanged, Qt::QueuedConnection)); Q_TEST(connect(&_saveWatcher, &QFutureWatcher<void>::finished, this, [&]() { _available = true; emit available(); }, Qt::QueuedConnection)); if (!_man || _url.isEmpty()) return; if (_url.startsWith("//")) _url = "http:" + _url; _hash = qHash(_url); if (_exists()) { _available = true; emit available(); return; } qDebug() << "CachedImage from url: " << url; if (_man->autoload()) download(); else getInfo(); }
int exists(const char *path) { return _exists(path, -1); }
int dir_exists(const char *path) { return _exists(path, 1); }
int file_exists(const char *path) { return _exists(path, 0); }
bool fs_t::exists(const std::string& path) const { return _exists(canocial(path).c_str()); }
constexpr bool exists(const std::tuple<Args...> &t){ return _exists(t,gens<sizeof...(Args)>::build()); }
int exists2(pool *p, const char *path) { return _exists(p, path, -1); }
int dir_exists2(pool *p, const char *path) { return _exists(p, path, 1); }
int file_exists2(pool *p, const char *path) { return _exists(p, path, 0); }