-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqzfileinfo.cpp
70 lines (57 loc) · 1.02 KB
/
qzfileinfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "qzfileinfo.h"
#include <qfileinfo.h>
#include "zipfs.h"
#include "qzfs.h"
QZFileInfo::QZFileInfo(QString str)
{
QCString zname, sname;
ZEntry *entry=NULL;
m_type = getNames(str, zname, sname, &entry);
if (m_type==QZF_NONE) return;
if (m_type&QZF_ZIP) {
m_dir.z = entry;
m_dir.z->grab();
} else {
m_dir.q = new QFileInfo(str);
}
}
QZFileInfo::~QZFileInfo()
{
if (m_type==QZF_NONE) return;
if (m_type&QZF_ZIP) {
m_dir.z->release();
} else {
delete m_dir.q;
}
}
QZFileInfo::QZFileInfo(ZEntry *entry)
{
if (!entry) m_type = QZF_NONE;
m_type = (entry->isDir() ? QZF_DIR : QZF_FILE)|QZF_ZIP;
m_dir.z = entry;
}
bool
QZFileInfo::isDir()
{
return (m_type&QZF_DIR)!=0;
}
bool
QZFileInfo::isFile()
{
return (m_type&QZF_FILE)!=0;
}
int
QZFileInfo::getType()
{
return m_type;
}
unsigned int
QZFileInfo::getSize()
{
if ((m_type&QZF_FILE)==0) return 0;
if (m_type&QZF_ZIP) {
return (unsigned int)((ZFileEntry*)m_dir.z)->m_size;
} else {
return m_dir.size();
}
}