Commit b1de54f8 by maarten

backup

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@176 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 141764ed
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/any.hpp> #include <boost/any.hpp>
#include <boost/filesystem/path.hpp>
#include "cif++/CifUtils.h" #include "cif++/CifUtils.h"
...@@ -1008,12 +1009,16 @@ class File ...@@ -1008,12 +1009,16 @@ class File
File(); File();
File(std::istream& is, bool validate = false); File(std::istream& is, bool validate = false);
File(boost::filesystem::path p, bool validate = false);
File(File&& rhs); File(File&& rhs);
File(const File& rhs) = delete; File(const File& rhs) = delete;
File& operator=(const File& rhs) = delete; File& operator=(const File& rhs) = delete;
~File(); ~File();
void load(boost::filesystem::path p);
void save(boost::filesystem::path p);
void load(std::istream& is); void load(std::istream& is);
void save(std::ostream& os); void save(std::ostream& os);
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#if defined(USE_RSRC) #if defined(USE_RSRC)
#include "cif++/mrsrc.h" #include "cif++/mrsrc.h"
...@@ -24,6 +27,7 @@ ...@@ -24,6 +27,7 @@
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace io = boost::iostreams;
extern int VERBOSE; extern int VERBOSE;
...@@ -1950,6 +1954,12 @@ File::File(istream& is, bool validate) ...@@ -1950,6 +1954,12 @@ File::File(istream& is, bool validate)
load(is); load(is);
} }
File::File(boost::filesystem::path p, bool validate)
: File()
{
load(p);
}
File::File(File&& rhs) File::File(File&& rhs)
: mHead(nullptr), mValidator(nullptr) : mHead(nullptr), mValidator(nullptr)
{ {
...@@ -1988,6 +1998,51 @@ void File::append(Datablock* e) ...@@ -1988,6 +1998,51 @@ void File::append(Datablock* e)
} }
} }
void File::load(fs::path p)
{
fs::ifstream inFile(p, ios_base::in | ios_base::binary);
if (not inFile.is_open())
throw runtime_error("Could not open file: " + p.string());
io::filtering_stream<io::input> in;
string ext;
if (p.extension() == ".bz2")
{
in.push(io::bzip2_decompressor());
ext = p.stem().extension().string();
}
else if (p.extension() == ".gz")
{
in.push(io::gzip_decompressor());
ext = p.stem().extension().string();
}
in.push(inFile);
load(in);
}
void File::save(fs::path p)
{
fs::ofstream outFile(p, ios_base::out | ios_base::binary);
io::filtering_stream<io::output> out;
if (p.extension() == ".gz")
{
out.push(io::gzip_compressor());
p = p.stem();
}
else if (p.extension() == ".bz2")
{
out.push(io::bzip2_compressor());
p = p.stem();
}
out.push(outFile);
save(out);
}
void File::load(istream& is) void File::load(istream& is)
{ {
Validator* saved = mValidator; Validator* saved = mValidator;
......
...@@ -2621,7 +2621,7 @@ void PDBFileParser::ParseRemark200() ...@@ -2621,7 +2621,7 @@ void PDBFileParser::ParseRemark200()
{ {
getCategory("diffrn_radiation_wavelength")->emplace({ getCategory("diffrn_radiation_wavelength")->emplace({
{ "id", wavelengthNr++ }, { "id", wavelengthNr++ },
{ "wavelength", wl }, { "wavelength", wl.empty() ? "." : wl },
{ "wt", "1.0" } { "wt", "1.0" }
}); });
} }
......
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