Commit 43cb3122 by Maarten L. Hekkelman

addFileResource added

parent ce28cb7a
......@@ -202,6 +202,7 @@ class Progress
// Resources
std::unique_ptr<std::istream> loadResource(std::filesystem::path name);
void addFileResource(const std::string &name, std::filesystem::path dataFile);
}
......
......@@ -1184,14 +1184,28 @@ namespace cif
// --------------------------------------------------------------------
std::map<std::string,std::filesystem::path> gLocalResources;
void addFileResource(const std::string &name, std::filesystem::path dataFile)
{
gLocalResources[name] = dataFile;
}
std::unique_ptr<std::istream> loadResource(std::filesystem::path name)
{
std::unique_ptr<std::istream> result;
fs::path p = name;
if (gLocalResources.count(name.string()))
{
std::unique_ptr<std::ifstream> file(new std::ifstream(gLocalResources[name.string()], std::ios::binary));
if (file->is_open())
result.reset(file.release());
}
#if defined(CACHE_DIR) and defined(DATA_DIR)
if (not fs::exists(p))
if (not result and not fs::exists(p))
{
for (const char *dir : {CACHE_DIR, DATA_DIR})
{
......@@ -1205,7 +1219,7 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name)
}
#endif
if (fs::exists(p))
if (not result and fs::exists(p))
{
std::unique_ptr<std::ifstream> file(new std::ifstream(p, std::ios::binary));
if (file->is_open())
......
......@@ -126,7 +126,7 @@ Compound::Compound(cif::Datablock &db)
CompoundAtom atom;
std::string typeSymbol;
cif::tie(atom.id, typeSymbol, atom.charge, atom.aromatic, atom.leavingAtom, atom.stereoConfig, atom.x, atom.y, atom.z) =
row.get("id", "type_symbol", "charge", "pdbx_aromatic_flag", "pdbx_leaving_atom_flag", "pdbx_stereo_config",
row.get("atom_id", "type_symbol", "charge", "pdbx_aromatic_flag", "pdbx_leaving_atom_flag", "pdbx_stereo_config",
"model_Cartn_x", "model_Cartn_y", "model_Cartn_z");
atom.typeSymbol = AtomTypeTraits(typeSymbol).type();
mAtoms.push_back(std::move(atom));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment