Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
webevd
webevd
WebEVD
Temporaries.cxx
Go to the documentation of this file.
1
#include "
webevd/WebEVD/Temporaries.h
"
2
3
#include "TString.h"
4
5
namespace
evd
6
{
7
// --------------------------------------------------------------------------
8
Temporaries::Temporaries
()
9
{
10
fTempDir
=
"/tmp/webevd_XXXXXX"
;
11
mkdtemp(
fTempDir
.data());
12
}
13
14
// --------------------------------------------------------------------------
15
Temporaries::~Temporaries
()
16
{
17
for
(
const
std::string
&
f
:
fCleanup
) unlink((
fTempDir
+
"/"
+
f
).c_str());
18
19
if
(
rmdir
(
fTempDir
.c_str()) != 0){
20
std::cout <<
"Failed to clean up temporary directory "
<<
fTempDir
<<
std::endl
;
21
}
22
}
23
24
// --------------------------------------------------------------------------
25
void
Temporaries::AddCleanup
(
const
std::string
&
fname
)
26
{
27
const
std::scoped_lock
l
(
fLock
);
28
fCleanup
.push_back(fname);
29
}
30
31
// --------------------------------------------------------------------------
32
FILE*
Temporaries::fopen
(
const
std::string
&
fname
,
const
char
* mode)
33
{
34
AddCleanup
(fname);
35
return ::fopen((
fTempDir
+
"/"
+fname).c_str(), mode);
36
}
37
38
// --------------------------------------------------------------------------
39
std::ofstream
Temporaries::ofstream
(
const
std::string
&
fname
)
40
{
41
AddCleanup
(fname);
42
return
std::ofstream(
fTempDir
+
"/"
+fname);
43
}
44
45
// --------------------------------------------------------------------------
46
int
Temporaries::symlink
(
const
std::string
&
dir
,
const
std::string
&
fname
)
47
{
48
AddCleanup
(fname);
49
return ::symlink
(
TString::Format
(
"%s/%s"
, dir.c_str(), fname.c_str()).
Data
(),
50
TString::Format
(
"%s/%s"
,
fTempDir
.c_str(), fname.c_str()).
Data
());
51
}
52
53
// --------------------------------------------------------------------------
54
std::string
Temporaries::compress
(
const
std::string
&
fname
)
55
{
56
const
std::string
tgt = fname+
".gz"
;
57
// Don't destroy original, use fastest compression
58
system((
"gzip -c -1 "
+
fTempDir
+
"/"
+fname+
" > "
+
fTempDir
+
"/"
+tgt).c_str());
59
AddCleanup
(tgt);
60
return
fTempDir
+
"/"
+tgt;
61
}
62
}
keras_to_tensorflow.f
f
Definition:
keras_to_tensorflow.py:162
evd::Temporaries::ofstream
std::ofstream ofstream(const std::string &fname)
Definition:
Temporaries.cxx:39
evd::Temporaries::Temporaries
Temporaries()
Definition:
Temporaries.cxx:8
Data
Definition:
RangeForWrapper_test.cc:81
string
std::string string
Definition:
nybbler.cc:12
evd::Temporaries::AddCleanup
void AddCleanup(const std::string &fname)
Definition:
Temporaries.cxx:25
evd::Temporaries::compress
std::string compress(const std::string &fname)
Definition:
Temporaries.cxx:54
evd::Temporaries::fopen
FILE * fopen(const std::string &fname, const char *mode)
Definition:
Temporaries.cxx:32
wirecell.sigproc.paper.noise.fname
fname
Definition:
noise.py:68
dir
string dir
Definition:
INukeNucleonCorr.cxx:59
python.emptydir.rmdir
def rmdir(dir, verbose)
Definition:
emptydir.py:155
l
static QStrList * l
Definition:
config.cpp:1044
python.larbatch_posix.symlink
def symlink(src, dest)
Definition:
larbatch_posix.py:818
evd
LArSoft includes.
Definition:
AnalysisBaseDrawer.cxx:40
evd::Temporaries::fLock
std::mutex fLock
Definition:
Temporaries.h:35
evd::Temporaries::fTempDir
std::string fTempDir
Definition:
Temporaries.h:32
evd::Temporaries::~Temporaries
~Temporaries()
Definition:
Temporaries.cxx:15
evd::Temporaries::symlink
int symlink(const std::string &dir, const std::string &fname)
Definition:
Temporaries.cxx:46
genie::utils::style::Format
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition:
Style.cxx:146
evd::Temporaries::fCleanup
std::vector< std::string > fCleanup
Definition:
Temporaries.h:33
Temporaries.h
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11