Switch to unified view

a/src/internfile/uncomp.cpp b/src/internfile/uncomp.cpp
...
...
16
 */
16
 */
17
17
18
#include "autoconfig.h"
18
#include "autoconfig.h"
19
19
20
#include <errno.h>
20
#include <errno.h>
21
#include <sys/stat.h>
22
21
23
#include <string>
22
#include <string>
24
#include <vector>
23
#include <vector>
25
#include <map>
24
#include <map>
26
using std::map;
27
using std::string;
28
using std::vector;
29
25
30
#include "uncomp.h"
26
#include "uncomp.h"
31
#include "debuglog.h"
27
#include "debuglog.h"
32
#include "smallut.h"
28
#include "smallut.h"
33
#include "execmd.h"
29
#include "execmd.h"
34
#include "pathut.h"
30
#include "pathut.h"
31
32
using std::map;
33
using std::string;
34
using std::vector;
35
35
36
Uncomp::UncompCache Uncomp::o_cache;
36
Uncomp::UncompCache Uncomp::o_cache;
37
37
38
bool Uncomp::uncompressfile(const string& ifn, 
38
bool Uncomp::uncompressfile(const string& ifn, 
39
                const vector<string>& cmdv, string& tfile)
39
                const vector<string>& cmdv, string& tfile)
...
...
68
    if (!fsocc(m_dir->dirname(), &pc, &availmbs)) {
68
    if (!fsocc(m_dir->dirname(), &pc, &availmbs)) {
69
        LOGERR(("uncompressfile: can't retrieve avail space for %s\n", 
69
        LOGERR(("uncompressfile: can't retrieve avail space for %s\n", 
70
                m_dir->dirname()));
70
                m_dir->dirname()));
71
        // Hope for the best
71
        // Hope for the best
72
    } else {
72
    } else {
73
        struct stat stb;
73
  long long fsize = path_filesize(ifn);
74
        if (stat(ifn.c_str(), &stb) < 0) {
74
        if (fsize < 0) {
75
            LOGERR(("uncompressfile: stat input file %s errno %d\n", 
75
            LOGERR(("uncompressfile: stat input file %s errno %d\n", 
76
                    ifn.c_str(), errno));
76
                    ifn.c_str(), errno));
77
            return false;
77
            return false;
78
        }
78
        }
79
        // We need at least twice the file size for the uncompressed
79
        // We need at least twice the file size for the uncompressed
80
        // and compressed versions. Most compressors don't store the
80
        // and compressed versions. Most compressors don't store the
81
        // uncompressed size, so we have no way to be sure that we
81
        // uncompressed size, so we have no way to be sure that we
82
        // have enough space before trying. We take a little margin
82
        // have enough space before trying. We take a little margin
83
83
84
        // use same Mb def as fsocc()
84
        // use same Mb def as fsocc()
85
        long long filembs = stb.st_size / (1024 * 1024); 
85
        long long filembs = fsize / (1024 * 1024); 
86
        
86
        
87
        if (availmbs < 2 * filembs + 1) {
87
        if (availmbs < 2 * filembs + 1) {
88
            LOGERR(("uncompressfile. %lld MBs available in %s not enough "
88
            LOGERR(("uncompressfile. %lld MBs available in %s not enough "
89
                    "to uncompress %s of size %lld mbs\n", availmbs,
89
                    "to uncompress %s of size %lld mbs\n", availmbs,
90
                    m_dir->dirname(), ifn.c_str(), filembs));
90
                    m_dir->dirname(), ifn.c_str(), filembs));