Beispiel #1
0
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.");
	}
}
Beispiel #2
0
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());
}
Beispiel #3
0
	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() );
	}
Beispiel #4
0
	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() );
	}
Beispiel #5
0
/**
* @brief Dumps class data to the file.
*
* Method dumps class data to the file in the same format as input file has.
*
* @param filePath Path of the file to create (empty means overwrite input file).
*/
void condor2nav::CFileParserINI::Dump(const bfs::path &filePath /* = "" */) const
{
  COStream ostream{filePath.empty() ? Path() : filePath};
  // dump global scope
  for(const auto &v : _valuesMap)
    ostream << v.first << "=" << v.second << std::endl;

  // dump chapters
  for(auto it=_chaptersList.begin(); it!=_chaptersList.end(); ++it) {
    if(it != _chaptersList.begin() || _valuesMap.size())
      ostream << std::endl;

    ostream << "[" << it->name << "]" << std::endl;
    for(const auto &v : it->valuesMap)
      ostream << v.first << "=" << v.second << std::endl;
  }
}
Beispiel #6
0
/** 
 * @brief Creates specified directory
 * 
 * Function creates given directory recursively.
 * 
 * @param dirName Directory name to created.
 *
 * @exception std::runtime_error Operation did not succeed
 */
void condor2nav::DirectoryCreate(const bfs::path &dirName)
{
  bool activeSync = false;
  const std::string str = dirName.string();
  if(str.size() > 2 && str[0] == '\\' && str[1] != '\\')
    activeSync = true;

  if(!dirName.empty()) {
    if(!activeSync) {
      bfs::create_directories(dirName);
    }
    else {
      auto path = dirName;
      std::vector<bfs::path> dirs;
      while(path.parent_path() != "\\") {
        dirs.emplace_back(path);
        path = path.parent_path();
      }
      auto &activeSync = CActiveSync::Instance();
      std::for_each(dirs.crbegin(), dirs.crend(),
                    [&](const bfs::path &d){ activeSync.DirectoryCreate(d); });
    }
  }
}