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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#include "MkPath.h"
MkPath::MkPath()
{
stopIt=false;
waitAction=false;
setObjectName("MkPath");
moveToThread(this);
start();
}
MkPath::~MkPath()
{
stopIt=true;
quit();
wait();
}
void MkPath::addPath(const QString &path)
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path);
if(stopIt)
return;
emit internalStartAddPath(path);
}
void MkPath::skip()
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
emit internalStartSkip();
}
void MkPath::retry()
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
emit internalStartRetry();
}
void MkPath::run()
{
connect(this,SIGNAL(internalStartAddPath(QString)),this,SLOT(internalAddPath(QString)),Qt::QueuedConnection);
connect(this,SIGNAL(internalStartDoThisPath()),this,SLOT(internalDoThisPath()),Qt::QueuedConnection);
connect(this,SIGNAL(internalStartSkip()),this,SLOT(internalSkip()),Qt::QueuedConnection);
connect(this,SIGNAL(internalStartRetry()),this,SLOT(internalRetry()),Qt::QueuedConnection);
exec();
}
void MkPath::internalDoThisPath()
{
if(waitAction || pathList.isEmpty())
return;
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+pathList.first());
if(!dir.exists(pathList.first()))
if(!dir.mkpath(pathList.first()))
{
if(!dir.exists(pathList.first()))
{
if(stopIt)
return;
waitAction=true;
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to remove the folder: "+pathList.first());
emit errorOnFolder(pathList.first(),tr("Unable to create the folder"));
return;
}
}
pathList.removeFirst();
emit firstFolderFinish();
checkIfCanDoTheNext();
}
void MkPath::internalAddPath(const QString &path)
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path);
pathList << path;
if(!waitAction)
checkIfCanDoTheNext();
}
void MkPath::checkIfCanDoTheNext()
{
if(!waitAction && !stopIt && pathList.size()>0)
emit internalStartDoThisPath();
}
void MkPath::internalSkip()
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
waitAction=false;
pathList.removeFirst();
emit firstFolderFinish();
checkIfCanDoTheNext();
}
void MkPath::internalRetry()
{
ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
waitAction=false;
checkIfCanDoTheNext();
}
|