Commit 8646684d authored by Stefan Hoeche's avatar Stefan Hoeche Committed by Enrico Bothmann

Resolve "replace sqlite by zip"

parent cc6873ff
......@@ -134,7 +134,7 @@ void AMEGIC::Single_LOProcess::WriteAlternativeName(string aname)
{
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"
+m_ptypename+"/"+m_name+".alt";
if (FileExists(altname,1)) return;
if (FileExists(altname)) return;
My_Out_File to(altname);
to.Open();
*to<<aname<<" "<<m_sfactor<<endl;
......@@ -151,7 +151,7 @@ bool AMEGIC::Single_LOProcess::CheckAlternatives(vector<Process_Base *>& links,
{
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"
+m_ptypename+"/"+procname+".alt";
if (FileExists(altname,1)) {
if (FileExists(altname)) {
double factor;
string name,dummy;
My_In_File from(altname);
......@@ -324,7 +324,7 @@ int AMEGIC::Single_LOProcess::InitAmplitude(Amegic_Model * model,Topology* top,
if (!FoundMappingFile(m_libname,m_pslibname)) {
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+Name();
if (FileExists(mlname+string(".map"),1)) {
if (FileExists(mlname+string(".map"))) {
if (m_sfactor==1.) My_In_File::CopyInDB(mlname+".map",mnname+".map");
else {
UpdateMappingFile(mlname,cplmap);
......@@ -497,7 +497,7 @@ int Single_LOProcess::InitAmplitude(Amegic_Model * model,Topology* top,
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+Name();
msg_Debugging()<<mlname<<std::endl<<mnname<<std::endl;
if (FileExists(mlname+string(".map"),1)) {
if (FileExists(mlname+string(".map"))) {
if (m_sfactor==1.) My_In_File::CopyInDB(mlname+".map",mnname+".map");
else {
UpdateMappingFile(mlname,cplmap);
......@@ -730,7 +730,7 @@ int Single_LOProcess::Tests(std::vector<double> * pfactors)
}
else {
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/")+testname+string("/V.H");
if (FileExists(searchfilename)) {
if (FileExists(searchfilename,1)) {
msg_Error()<<"ERROR in Single_LOProcess::Tests()"<<std::endl
<<" No compiled & linked library found for process "<<testname<<std::endl
<<" but files already written out !"<<std::endl
......@@ -1044,15 +1044,15 @@ void Single_LOProcess::WriteLibrary()
m_libname = CreateLibName();
if (p_partner==this) m_pslibname = m_libname;
else m_pslibname = p_partner->PSLibName();
if (!FileExists(newpath+m_ptypename+string("/")+m_libname+string("/V.H"))) {
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname);
if (!FileExists(newpath+m_ptypename+string("/")+m_libname+string("/V.H"),1)) {
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname,true);
p_shand->Output(p_hel,m_ptypename+string("/")+m_libname);
}
CreateMappingFile(this);
p_BS->Output(newpath+m_ptypename+string("/")+m_libname);
p_ampl->StoreAmplitudeConfiguration(newpath+m_ptypename+string("/")+m_libname);
m_newlib=true;
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs"))
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs",1))
Copy(rpa->gen.Variable("SHERPA_SHARE_PATH")+"/makelibs",
rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs");
msg_Info()<<"AMEGIC::Single_Process::WriteLibrary : "<<std::endl
......@@ -1063,7 +1063,7 @@ void Single_LOProcess::WriteLibrary()
void Single_LOProcess::CreateMappingFile(Single_LOProcess* partner) {
if (m_gen_str<2) return;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname,1)) {
if (FileExists(outname)) {
string MEname,PSname;
FoundMappingFile(MEname,PSname);
if (MEname != m_libname || PSname != m_pslibname) {
......@@ -1094,7 +1094,7 @@ bool Single_LOProcess::FoundMappingFile(std::string & MEname, std::string & PSna
std::string buf;
int pos;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname,1)) {
if (FileExists(outname)) {
My_In_File from(outname);
from.Open();
getline(*from,buf);
......@@ -1117,7 +1117,7 @@ bool Single_LOProcess::FoundLib(std::string& pID)
{
std::string libname=ATOOLS::rpa->gen.Variable("SHERPA_LIB_PATH")+
std::string("/libProc_P")+pID.substr(1)+std::string(LIB_SUFFIX);
if (FileExists(libname)) return 1;
if (FileExists(libname,1)) return 1;
return 0;
}
......
......@@ -304,7 +304,9 @@ bool AMEGIC::Single_Real_Correction::FillIntegrator
(PHASIC::Phase_Space_Handler *const psh)
{
if (p_partner!=this) return true;
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (!SetUpIntegrator()) THROW(fatal_error,"No integrator");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (m_pinfo.m_nlomode==nlo_mode::powheg) return true;
return p_tree_process->FillIntegrator(psh);
}
......
......@@ -447,7 +447,9 @@ bool AMEGIC::Single_Virtual_Correction::FillIntegrator
{
if (p_partner!=this) return true;
if (p_LO_process!=p_LO_process->Partner()) return 1;
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (!SetUpIntegrator()) THROW(fatal_error,"No integrator");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
RequestVariables(psh);
return Process_Base::FillIntegrator(psh);
}
......
......@@ -83,7 +83,6 @@ Amegic::Amegic():
Amegic::~Amegic()
{
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
delete p_amodel;
}
......@@ -293,7 +292,7 @@ bool Amegic::Initialize(const std::string &path,const std::string &file,
AMEGIC::Process_Base::SetGauge(ToType<double>(rpa->gen.Variable("AMEGIC_DEFAULT_GAUGE")));
s_partcommit = reader.Get("AMEGIC_PARTIAL_COMMIT", 0, "partial commit", METHOD);
MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process",true);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
return true;
}
......@@ -317,18 +316,16 @@ PHASIC::Process_Base *Amegic::InitializeProcess(const PHASIC::Process_Info &pi,
delete newxs;
return NULL;
}
if (!s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","begin");
if (!newxs->Get<AMEGIC::Process_Group>()->ConstructProcesses()) {
if (!s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
msg_Debugging()<<METHOD<<"(): Construct failed for '"
<<newxs->Name()<<"'\n";
delete newxs;
return NULL;
}
if (!s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
newxs->Get<AMEGIC::Process_Group>()->WriteMappingFile();
msg_Tracking()<<"Initialized '"<<newxs->Name()<<"'\n";
if (msg_LevelIsTracking()) newxs->Get<AMEGIC::Process_Group>()->PrintProcessSummary();
......@@ -366,16 +363,15 @@ PHASIC::Process_Base *Amegic::InitializeProcess(const PHASIC::Process_Info &pi,
// msg_Debugging()<<"} -> sum = "<<sum<<"\n";
newxs->Get<AMEGIC::Process_Base>()->SetTestMoms(p_testmoms);
newxs->Get<AMEGIC::Process_Base>()->SetPrintGraphs(pi.m_gpath);
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","begin");
if (!newxs->Get<AMEGIC::Process_Base>()->
InitAmplitude(p_amodel,&top,m_umprocs,m_errprocs)) {
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
msg_Debugging()<<METHOD<<"(): Init failed for '"
<<newxs->Name()<<"'\n";
delete newxs;
return NULL;
}
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
}
if (add) Add(newxs,1);
else m_rsprocs.push_back(newxs);
......@@ -390,6 +386,7 @@ int Amegic::PerformTests()
for (size_t i(0);i<m_rsprocs.size();++i)
if (m_rsprocs[i]->Get<AMEGIC::Amegic_Base>()->NewLibs()) return -1;
Minimize();
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
return tests;
}
......
......@@ -114,11 +114,9 @@ bool AMEGIC::Process_Group::Initialize(PHASIC::Process_Base *const proc)
AMEGIC::Process_Base* apb=proc->Get<AMEGIC::Process_Base>();
apb->SetPrintGraphs(m_pinfo.m_gpath);
apb->SetTestMoms(p_testmoms);
if (s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","begin");
int res=apb->InitAmplitude(p_model,p_top,m_umprocs,m_errprocs);
if (s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
if (res) proc->SetParent((PHASIC::Process_Base*)this);
return res;
}
......@@ -166,11 +164,9 @@ bool AMEGIC::Process_Group::SetUpIntegrator()
{
if (p_parent==NULL || (*p_parent)[0]->IsGroup()/* this is fudgy, need mode ... */) {
for (size_t i(0);i<m_procs.size();i++) {
if (s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","begin");
int res=m_procs[i]->Get<AMEGIC::Process_Base>()->SetUpIntegrator();
if (s_partcommit)
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/",0);
if (!res) return false;
}
}
......@@ -217,7 +213,9 @@ bool AMEGIC::Process_Group::FillIntegrator
m_procs[i]->Get<AMEGIC::Process_Base>()->RequestVariables(psh);
Multi_Channel *mc(psh->FSRIntegrator());
if (mc==NULL) return true;
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (!SetUpIntegrator()) THROW(fatal_error,"No integrator");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (p_channellibnames->empty()) return true;
for (std::list<std::string>::iterator it(p_channellibnames->begin());
it!=p_channellibnames->end();++it) {
......
......@@ -63,7 +63,7 @@ void AMEGIC::Single_Process::WriteAlternativeName(string aname)
{
if (aname==m_name) return;
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".alt";
if (FileExists(altname,1)) return;
if (FileExists(altname)) return;
My_Out_File to(altname);
to.Open();
*to<<aname<<" "<<m_sfactor<<endl;
......@@ -75,7 +75,7 @@ void AMEGIC::Single_Process::WriteAlternativeName(string aname)
bool AMEGIC::Single_Process::CheckAlternatives(vector<Process_Base *>& links,string procname)
{
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+procname+".alt";
if (FileExists(altname,1)) {
if (FileExists(altname)) {
double factor;
string name,dummy;
My_In_File from(altname);
......@@ -177,7 +177,7 @@ int AMEGIC::Single_Process::InitAmplitude(Amegic_Model *model,Topology* top,
if (!FoundMappingFile(m_libname,m_pslibname)) {
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+Name();
if (FileExists(mlname+string(".map"),1)) {
if (FileExists(mlname+string(".map"))) {
if (m_sfactor==1.) My_In_File::CopyInDB(mlname+".map",mnname+".map");
else {
UpdateMappingFile(mlname,cplmap);
......@@ -387,7 +387,7 @@ int AMEGIC::Single_Process::Tests()
}
else {
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/")+testname+string("/V.H");
if (FileExists(searchfilename)) {
if (FileExists(searchfilename,1)) {
msg_Error()<<"ERROR in AMEGIC::Single_Process::Tests()"<<std::endl
<<" No compiled & linked library found for process "<<testname<<std::endl
<<" but files already written out !"<<std::endl
......@@ -609,15 +609,15 @@ void AMEGIC::Single_Process::WriteLibrary()
m_libname = CreateLibName();
if (p_partner==this) m_pslibname = m_libname;
else m_pslibname = p_partner->PSLibName();
if (!FileExists(newpath+m_ptypename+string("/")+m_libname+string("/V.H"))) {
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname);
if (!FileExists(newpath+m_ptypename+string("/")+m_libname+string("/V.H"),1)) {
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname,true);
p_shand->Output(p_hel,m_ptypename+string("/")+m_libname);
}
CreateMappingFile(this);
p_BS->Output(newpath+m_ptypename+string("/")+m_libname);
p_ampl->StoreAmplitudeConfiguration(newpath+m_ptypename+string("/")+m_libname);
m_newlib=true;
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs"))
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs",1))
Copy(rpa->gen.Variable("SHERPA_SHARE_PATH")+"/makelibs",
rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs");
msg_Info()<<"AMEGIC::Single_Process::WriteLibrary : "<<std::endl
......@@ -628,7 +628,7 @@ void AMEGIC::Single_Process::WriteLibrary()
void AMEGIC::Single_Process::CreateMappingFile(Single_Process* partner) {
if (m_gen_str<2) return;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname,1)) {
if (FileExists(outname)) {
string MEname,PSname;
FoundMappingFile(MEname,PSname);
if (MEname != m_libname || PSname != m_pslibname) {
......@@ -652,7 +652,7 @@ bool AMEGIC::Single_Process::FoundMappingFile(std::string & MEname, std::string
std::string buf;
int pos;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname,1)) {
if (FileExists(outname)) {
My_In_File from(outname);
from.Open();
getline(*from,buf);
......@@ -704,7 +704,9 @@ bool AMEGIC::Single_Process::FillIntegrator
(PHASIC::Phase_Space_Handler *const psh)
{
if (p_partner!=this) return true;
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (!SetUpIntegrator()) THROW(fatal_error,"No integrator");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
return Process_Base::FillIntegrator(psh);
}
......
......@@ -367,7 +367,7 @@ int AMEGIC::Single_Process_Combined::Tests()
}
else {
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/")+testname+string("/V.H");
if (FileExists(searchfilename)) {
if (FileExists(searchfilename,1)) {
msg_Error()<<"ERROR in AMEGIC::Single_Process_Combined::Tests()"<<std::endl
<<" No compiled & linked library found for process "<<testname<<std::endl
<<" but files already written out !"<<std::endl
......@@ -588,19 +588,19 @@ void AMEGIC::Single_Process_Combined::WriteLibrary()
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/");
for (;;) {
testname = CreateLibName()+string("_")+ToString(m_libnumb);
if (!(FileExists(newpath+m_ptypename+string("/")+testname+string("/V.H")))) break;
if (!(FileExists(newpath+m_ptypename+string("/")+testname+string("/V.H"),1))) break;
++m_libnumb;
}
m_libname = testname;
if (p_partner==this) m_pslibname = m_libname;
else m_pslibname = p_partner->PSLibName();
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname);
ATOOLS::MakeDir(newpath+m_ptypename+"/"+m_libname,true);
p_shand->Output(p_hel,m_ptypename+string("/")+m_libname);
CreateMappingFile(this);
p_BS->Output(newpath+m_ptypename+string("/")+m_libname);
p_ampl->StoreAmplitudeConfiguration(newpath+m_ptypename+string("/")+m_libname);
m_newlib=true;
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs"))
if (!FileExists(rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs",1))
Copy(rpa->gen.Variable("SHERPA_SHARE_PATH")+"/makelibs",
rpa->gen.Variable("SHERPA_CPP_PATH")+"/makelibs");
msg_Info()<<"AMEGIC::Single_Process_Combined::WriteLibrary : "<<std::endl
......@@ -687,7 +687,9 @@ bool AMEGIC::Single_Process_Combined::FillIntegrator
(PHASIC::Phase_Space_Handler *const psh)
{
if (p_partner!=this) return true;
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (!SetUpIntegrator()) THROW(fatal_error,"No integrator");
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
return Process_Base::FillIntegrator(psh);
}
......
......@@ -57,7 +57,7 @@ int AMEGIC::Single_Process_External::InitAmplitude(Amegic_Model * model,Topology
m_newlib = false;
string ptypename;
ptypename = "P"+ToString(m_nin)+"_"+ToString(m_nout);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+ptypename,true);
m_Norm = SymmetryFactors() * m_pol.Spin_Average(m_nin,&m_flavs.front());
m_pn=m_flavs.size();
......
......@@ -147,7 +147,7 @@ bool Phase_Space_Generator::Construct(std::list<std::string>* liblist,string _pa
fsrpath = fsrpath0 + string(hlp);
fsrp = path+string("/")+fsrpath;
}
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+fsrp);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+fsrp,true);
String_Library slib(1);
slib.InitMakefile(fsrp);
}
......
......@@ -441,9 +441,6 @@ void Histogram::Output() {
void Histogram::Output(const std::string name)
{
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()) return;
#endif
if (!m_active) return;
My_Out_File ofile(name);
ofile.Open();
......
......@@ -23,6 +23,7 @@ libToolsOrg_la_SOURCES = \
My_MPI.C \
Exception.C \
Terminator_Objects.C \
libzippp.cpp \
My_File.C \
File_IO_Base.C \
Read_Write_Base.C \
......@@ -38,7 +39,6 @@ libToolsOrg_la_SOURCES = \
Integration_Info.C \
Library_Loader.C \
Command_Line_Interface.C \
libzippp.cpp \
$(GZIPSTREAMSOURCES) \
binreloc.c
......@@ -57,6 +57,7 @@ localinc_HEADERS = \
My_MPI.H \
Exception.H \
Terminator_Objects.H \
libzippp.h \
My_File.H \
File_IO_Base.H \
Read_Write_Base.H \
......@@ -82,13 +83,12 @@ localinc_HEADERS = \
Enum_Flags.H \
Node.H \
Node.C \
libzippp.h \
$(GZIPSTREAMHEADERS) \
binreloc.h
libToolsOrg_la_LIBADD = @CONDITIONAL_GZIPLIBS@ @SQLITE3_LDFLAGS@ @LIBZIP_LDFLAGS@
libToolsOrg_la_LIBADD = @CONDITIONAL_GZIPLIBS@ @LIBZIP_LDFLAGS@
libToolsOrg_la_CPPFLAGS = $(AM_CPPFLAGS) @CONDITIONAL_GZIPINCS@ @SQLITE3_CFLAGS@ @LIBZIP_CPPFLAGS@
libToolsOrg_la_CPPFLAGS = $(AM_CPPFLAGS) @CONDITIONAL_GZIPINCS@ @LIBZIP_CPPFLAGS@
EXTRA_DIST = $(GZIPEXTRADIST) CXXFLAGS.H.in
......
This diff is collapsed.
......@@ -43,8 +43,6 @@ namespace ATOOLS {
fom::code m_mode;
static std::string s_sqlopenflag;
public:
// constructor
......@@ -73,15 +71,13 @@ namespace ATOOLS {
// static member functions
static bool OpenDB(std::string file);
static bool CloseDB(std::string file);
static bool CloseDB(std::string file,int mode=1);
static bool FileInDB(const std::string &name);
static bool ExecDB(std::string file,
const std::string &cmd);
static bool CopyInDB(std::string oldfile, std::string newfile);
inline static void SetSQLOpenFlag(const std::string &flag)
{ s_sqlopenflag=flag; }
std::string FileContent() const
{ return p_stream!=NULL?p_stream->str():""; }
};// end of class My_File
......@@ -94,7 +90,4 @@ namespace ATOOLS {
#define My_In_File ATOOLS::My_File<std::ifstream>
#define My_Out_File ATOOLS::My_File<std::ofstream>
template <class FileType>
std::string ATOOLS::My_File<FileType>::s_sqlopenflag="";
#endif
......@@ -12,13 +12,6 @@ String_Vector Read_Write_Base::s_commandline;
Buffer_Map Read_Write_Base::s_buffermap;
String_Map Read_Write_Base::s_globaltags;
// Zip:
typedef std::map<std::string, std::map<std::string, std::pair
<ZipEntry,std::string> > > DataBase_Map_Zip;
static DataBase_Map_Zip zip_databases;
Read_Write_Base::Read_Write_Base(const unsigned int infiles,
const unsigned int outfiles):
File_IO_Base(infiles,outfiles),
......@@ -402,175 +395,6 @@ void Read_Write_Base::AddCommandLine(const String_Vector &commandline)
commandline.begin(),commandline.end());
}
void ListZipEntries(std::string archive)
{
std::string path = archive; // path = /home/../Decaydata/
while (archive.length() && archive[archive.length()-1]=='/') {
archive.erase(archive.length()-1,1);
}
archive+=".zip";
ZipArchive zf(archive);
zf.open(ZipArchive::WRITE);
std::vector<ZipEntry> entries = zf.getEntries();
for(std::vector<ZipEntry>::iterator iter=entries.begin();
iter!=entries.end(); ++iter) {
ZipEntry entry = *iter;
std::string name = entry.getName();
while (name[0]!='/' && name!=nullstring ) {
name.erase(name.begin());
if (name[0]=='/') {
name.erase(name.begin());
break;
}
}
std::string content = entry.readAsText();
zip_databases[path][name]=std::pair<ZipEntry,std::string>(entry,content);
}
zf.close();
}
bool Read_Write_Base::OpenZip(std::string archive)
{
std::string list = archive;
if (archive.substr(archive.length()-4,4)==".zip") {
list.replace(list.length()-4, 4, "/");
}
else if (archive[archive.length()-1]!='/') {
archive+=".zip";
list+="/";
}
else if (archive[archive.length()-1]=='/') {
archive.replace(archive.length()-1,1,".zip");
}
ZipArchive zf(archive);
if (!zf.isOpen() && zf.open(ZipArchive::WRITE)!=true) {
return false;
}
else if (!zf.isOpen() && zf.open(ZipArchive::WRITE)==true) {
zf.open(ZipArchive::WRITE);
ListZipEntries(list);
return true;
}
else if (zf.open(ZipArchive::WRITE)==true) {
zf.open(ZipArchive::WRITE);
ListZipEntries(list);
return true;
}
return false;
}
bool Read_Write_Base::CloseZip(std::string archive)
{
std::string close = archive;
if (archive.substr(archive.length()-4,4)==".zip") {
close.replace(close.length()-4, 4, "/");
}
else if (archive[archive.length()-1]!='/') {
archive+=".zip";
close+="/";
}
else if (archive[archive.length()-1]=='/') {
archive.replace(archive.length()-1,1,".zip");
}
ZipArchive zf(archive);
int res=zf.close();
if (res!=LIBZIPPP_OK) {
msg_Error()<<"Could not close '"<<archive<<"'."<<std::endl
<<"Ignoring." <<std::endl;
}
zip_databases[close].clear();
return !res;
}
std::string Read_Write_Base::GetZipFileContent(std::string path,
std::string file)
{
std::map<std::string,std::pair<ZipEntry,std::string> >::
const_iterator pos=zip_databases[path].find(file);
if (pos==zip_databases[path].end()) {
return nullstring;
}
else {
std::string content = pos->second.second;
return content;
}
}
bool Read_Write_Base::FileInZip(std::string path,const std::string entry)
{
std::map<std::string,std::pair<ZipEntry,std::string> >::
const_iterator sit = zip_databases[path].find(entry);
if (sit!=zip_databases[path].end()) return true;
return false;
}
bool Read_Write_Base::AddZipEntry(std::string archive, std::string
path, int edit, std::string content,
std::string file)
{
std::string entry;
if (archive[archive.length()-1]!='/') archive+="/";
// get entry in right form: entry = "archive/folder/file"
std::pair<std::string,std::string> get_entry =
Read_Write_Base::SplitFilePath(archive,path,file,false);
entry = get_entry.second;
std::pair<std::string,std::string> path_file =
Read_Write_Base::SplitFilePath(archive,path,file);
path = path_file.first;
file = path_file.second;
archive=path.substr(0,path.length()-1)+".zip";
ZipArchive zf(archive);
zf.open(ZipArchive::WRITE);
const char *data = content.c_str();
if(!FileInZip(path,file)) {
zf.addData(entry,data,content.length());
return true;
}
else if (edit) {
zf.deleteEntry(entry);
zf.addData(entry,data,content.length());
return true;
}
else return false;
}
std::pair<std::string,std::string> Read_Write_Base::SplitFilePath
(std::string parser, std::string path, std::string file,
bool extend_path)
{
size_t found_p = path.rfind(parser);
size_t found_f = file.rfind(parser);
if (found_p!=std::string::npos) {
if (extend_path) {
file = path.substr(found_p+parser.size())+file;
path.erase(found_p+parser.size(), path.size()-found_p);
return std::pair<std::string,std::string>(path,file);
}
else {
file = path.substr(found_p)+file;
path.erase(found_p, path.size()-1);
return std::pair<std::string,std::string>(path,file);
}
}
else if (found_f!=std::string::npos) {
if (extend_path) {
path = path + file.substr(0,found_f+parser.size());
file = file.erase(0,found_f+parser.size());
return std::pair<std::string,std::string>(path,file);
}
else {
path = path + file.substr(0,found_f);
file = file.erase(0,found_f);
return std::pair<std::string,std::string>(path,file);
}
}
else return std::pair<std::string,std::string>(path,file);
}
bool Read_Write_Base::OpenInFile(const unsigned int i,const int mode)
{
if (InputPath(i)+InputFile(i)==nullstring) {
......
......@@ -7,8 +7,6 @@
#include <map>
#include <algorithm> // for find function
#include "ATOOLS/Org/libzippp.h"
using namespace libzippp;
namespace ATOOLS {
......@@ -104,12 +102,6 @@ namespace ATOOLS {
public:
typedef std::map<std::string,std::pair
<ZipEntry,std::string> > DataBase_Map_Zip;
typedef std::vector<ZipEntry> DataBase;
typedef std::vector<std::string> DataBase_str;
// constructors
Read_Write_Base(const unsigned int infiles,
const unsigned int outfiles);
......@@ -127,18 +119,6 @@ namespace ATOOLS {
void CloseInFile(const unsigned int i=0,const int mode=0);
void CloseOutFile(const unsigned int i=0,const int mode=0);
// Zip | static member functions
static std::string GetZipFileContent(std::string path, std::string file);
static bool OpenZip(std::string archive);
static bool CloseZip(std::string archive);
static bool FileInZip(std::string path, const std::string entry);
static bool AddZipEntry(std::string archive, std::string path,
int edit, std::string content, std::string file="");
static std::pair<std::string,std::string> SplitFilePath
(std::string parser,std::string path,
std::string file="", bool extend_path=true);
std::string StripEscapes(const std::string &buffer) const;
void AddFileContent(std::string line,const unsigned int i=0);
......
......@@ -251,9 +251,6 @@ void Run_Parameter::Init(std::string path,std::string file)
reader.SetAllowUnits(false);
s_loader->AddPath(rpa->gen