tabs and indents
This commit is contained in:
parent
19149020e3
commit
126ac47dba
@ -36,36 +36,36 @@ using std::vector;
|
|||||||
Uncomp::UncompCache Uncomp::o_cache;
|
Uncomp::UncompCache Uncomp::o_cache;
|
||||||
|
|
||||||
Uncomp::Uncomp(bool docache)
|
Uncomp::Uncomp(bool docache)
|
||||||
: m_docache(docache)
|
: m_docache(docache)
|
||||||
{
|
{
|
||||||
LOGDEB0("Uncomp::Uncomp: m_docache: " << m_docache << "\n");
|
LOGDEB0("Uncomp::Uncomp: m_docache: " << m_docache << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Uncomp::uncompressfile(const string& ifn,
|
bool Uncomp::uncompressfile(const string& ifn,
|
||||||
const vector<string>& cmdv, string& tfile)
|
const vector<string>& cmdv, string& tfile)
|
||||||
{
|
{
|
||||||
if (m_docache) {
|
if (m_docache) {
|
||||||
std::unique_lock<std::mutex> lock(o_cache.m_lock);
|
std::unique_lock<std::mutex> lock(o_cache.m_lock);
|
||||||
if (!o_cache.m_srcpath.compare(ifn)) {
|
if (!o_cache.m_srcpath.compare(ifn)) {
|
||||||
m_dir = o_cache.m_dir;
|
m_dir = o_cache.m_dir;
|
||||||
m_tfile = tfile = o_cache.m_tfile;
|
m_tfile = tfile = o_cache.m_tfile;
|
||||||
m_srcpath = ifn;
|
m_srcpath = ifn;
|
||||||
o_cache.m_dir = 0;
|
o_cache.m_dir = 0;
|
||||||
o_cache.m_srcpath.clear();
|
o_cache.m_srcpath.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_srcpath.clear();
|
m_srcpath.clear();
|
||||||
m_tfile.clear();
|
m_tfile.clear();
|
||||||
if (m_dir == 0) {
|
if (m_dir == 0) {
|
||||||
m_dir = new TempDir;
|
m_dir = new TempDir;
|
||||||
}
|
}
|
||||||
// Make sure tmp dir is empty. we guarantee this to filters
|
// Make sure tmp dir is empty. we guarantee this to filters
|
||||||
if (!m_dir || !m_dir->ok() || !m_dir->wipe()) {
|
if (!m_dir || !m_dir->ok() || !m_dir->wipe()) {
|
||||||
LOGERR("uncompressfile: can't clear temp dir " << m_dir->dirname() <<
|
LOGERR("uncompressfile: can't clear temp dir " << m_dir->dirname() <<
|
||||||
"\n");
|
"\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that we have enough available space to have some hope of
|
// Check that we have enough available space to have some hope of
|
||||||
@ -77,7 +77,7 @@ bool Uncomp::uncompressfile(const string& ifn,
|
|||||||
m_dir->dirname() << "\n");
|
m_dir->dirname() << "\n");
|
||||||
// Hope for the best
|
// Hope for the best
|
||||||
} else {
|
} else {
|
||||||
long long fsize = path_filesize(ifn);
|
long long fsize = path_filesize(ifn);
|
||||||
if (fsize < 0) {
|
if (fsize < 0) {
|
||||||
LOGERR("uncompressfile: stat input file " << ifn << " errno " <<
|
LOGERR("uncompressfile: stat input file " << ifn << " errno " <<
|
||||||
errno << "\n");
|
errno << "\n");
|
||||||
@ -109,22 +109,22 @@ bool Uncomp::uncompressfile(const string& ifn,
|
|||||||
subs['f'] = ifn;
|
subs['f'] = ifn;
|
||||||
subs['t'] = m_dir->dirname();
|
subs['t'] = m_dir->dirname();
|
||||||
for (; it != cmdv.end(); it++) {
|
for (; it != cmdv.end(); it++) {
|
||||||
string ns;
|
string ns;
|
||||||
pcSubst(*it, ns, subs);
|
pcSubst(*it, ns, subs);
|
||||||
args.push_back(ns);
|
args.push_back(ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute command and retrieve output file name, check that it exists
|
// Execute command and retrieve output file name, check that it exists
|
||||||
ExecCmd ex;
|
ExecCmd ex;
|
||||||
int status = ex.doexec(cmd, args, 0, &tfile);
|
int status = ex.doexec(cmd, args, 0, &tfile);
|
||||||
if (status || tfile.empty()) {
|
if (status || tfile.empty()) {
|
||||||
LOGERR("uncompressfile: doexec: " << cmd << " " <<
|
LOGERR("uncompressfile: doexec: " << cmd << " " <<
|
||||||
stringsToString(args) << " failed for [" <<
|
stringsToString(args) << " failed for [" <<
|
||||||
ifn << "] status 0x" << status << "\n");
|
ifn << "] status 0x" << status << "\n");
|
||||||
if (!m_dir->wipe()) {
|
if (!m_dir->wipe()) {
|
||||||
LOGERR("uncompressfile: wipedir failed\n");
|
LOGERR("uncompressfile: wipedir failed\n");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rtrimstring(tfile, "\n\r");
|
rtrimstring(tfile, "\n\r");
|
||||||
m_tfile = tfile;
|
m_tfile = tfile;
|
||||||
@ -138,12 +138,12 @@ Uncomp::~Uncomp()
|
|||||||
(m_dir?m_dir->dirname():"(null)") << "\n");
|
(m_dir?m_dir->dirname():"(null)") << "\n");
|
||||||
if (m_docache) {
|
if (m_docache) {
|
||||||
std::unique_lock<std::mutex> lock(o_cache.m_lock);
|
std::unique_lock<std::mutex> lock(o_cache.m_lock);
|
||||||
delete o_cache.m_dir;
|
delete o_cache.m_dir;
|
||||||
o_cache.m_dir = m_dir;
|
o_cache.m_dir = m_dir;
|
||||||
o_cache.m_tfile = m_tfile;
|
o_cache.m_tfile = m_tfile;
|
||||||
o_cache.m_srcpath = m_srcpath;
|
o_cache.m_srcpath = m_srcpath;
|
||||||
} else {
|
} else {
|
||||||
delete m_dir;
|
delete m_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,8 @@ public:
|
|||||||
* temporary directory).
|
* temporary directory).
|
||||||
*/
|
*/
|
||||||
bool uncompressfile(const std::string& ifn,
|
bool uncompressfile(const std::string& ifn,
|
||||||
const std::vector<std::string>& cmdv,
|
const std::vector<std::string>& cmdv,
|
||||||
std::string& tfile);
|
std::string& tfile);
|
||||||
static void clearcache();
|
static void clearcache();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -48,14 +48,14 @@ private:
|
|||||||
|
|
||||||
class UncompCache {
|
class UncompCache {
|
||||||
public:
|
public:
|
||||||
UncompCache() {}
|
UncompCache() {}
|
||||||
~UncompCache() {
|
~UncompCache() {
|
||||||
delete m_dir;
|
delete m_dir;
|
||||||
}
|
}
|
||||||
std::mutex m_lock;
|
std::mutex m_lock;
|
||||||
TempDir *m_dir{0};
|
TempDir *m_dir{0};
|
||||||
std::string m_tfile;
|
std::string m_tfile;
|
||||||
std::string m_srcpath;
|
std::string m_srcpath;
|
||||||
};
|
};
|
||||||
static UncompCache o_cache;
|
static UncompCache o_cache;
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user