-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchFile.cpp
65 lines (50 loc) · 1.56 KB
/
ArchFile.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
#include "../ArchFile.h"
#include "../ArchWorker.h"
namespace Arch
{
// -------------------------------------------------------------------------------------
File::File()
{
}
File::File(const QString& fileName)
: m_fileName(fileName)
{
}
File::~File()
{
}
void File::calcAddionalParams(uint32_t width)
{
if (!width)
{
m_realRowWidth = 0;
m_paddingSize = 0;
m_blockCount = 0;
return;
}
if (width % BLOCK_SIZE == 0)
m_realRowWidth = width;
else
{
m_paddingSize = BLOCK_SIZE - (width % BLOCK_SIZE);
m_realRowWidth = width + m_paddingSize;
}
m_blockCount = m_realRowWidth / BLOCK_SIZE;
}
// -------------------------------------------------------------------------------------
std::string removeExtension(std::string const& filename)
{
std::string::const_reverse_iterator pivot = std::find( filename.rbegin(), filename.rend(), '.' );
return pivot == filename.rend() ? filename : std::string( filename.begin(), pivot.base() - 1 );
}
std::string getWorkDir(int &argc, char** argv)
{
QDir dir;
if (argc >= 2)
dir = QDir(argv[1]);
if (!dir.exists())
dir = QDir::currentPath();
return dir.absolutePath().toStdString();
}
// -------------------------------------------------------------------------------------
}