-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxBupSummary.cpp
356 lines (341 loc) · 11.5 KB
/
wxBupSummary.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/*-----------------------------------------------------------------
* Name: wxBupSummary.cpp
* Purpose:
* Author: A. Wiegert
*
* Copyright:
* Licence: wxWidgets licence
*---------------------------------------------------------------- */
/*----------------------------------------------------------------
* Standard wxWidgets headers
*---------------------------------------------------------------- */
// Note __VISUALC__ is defined by wxWidgets, not by MSVC IDE
// and thus won't be defined until some wxWidgets headers are included
#if defined( _MSC_VER )
# if defined ( _DEBUG )
// this statement NEEDS to go BEFORE all headers
# define _CRTDBG_MAP_ALLOC
# endif
#endif
#include "wxBupPreProcDefsh.h" // needs to be first
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
/* For all others, include the necessary headers
* (this file is usually all you need because it
* includes almost all "standard" wxWidgets headers) */
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
// ------------------------------------------------------------------
#include "wxBupFrameh.h"
#include <wx/tokenzr.h>
// ------------------------------------------------------------------
#if defined( _MSC_VER ) // from Autohotkey-hummer.ahk
// this block needs to AFTER all headers
#include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif
#endif
extern jobPrefs_t g_jobData;
// ------------------------------------------------------------------
void MyFrame::UpdateSummary( wxString a_wsJobFileName, wxString a_wsJobFilePath,
wxString a_wsTimeBreakout )
{
wxString wsT;
wxString wsT1;
m_richTextCtrlSummary->Clear();
m_richTextCtrlSummary->SetDefaultStyle(wxRichTextAttr());
m_richTextCtrlSummary->Freeze();
m_richTextCtrlSummary->BeginSuppressUndo();
m_richTextCtrlSummary->BeginAlignment(wxTEXT_ALIGNMENT_CENTRE);
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->BeginFontSize(10);
wxString lineBreak = (wxChar) 29;
m_richTextCtrlSummary->WriteText( wxString( _("General Information")) );
m_richTextCtrlSummary->EndFontSize();
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->Newline();
// if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
// (m_JobTypeInProgress == MY_RESTORE_JOB) ||
// (m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Job File Name: ") );
m_richTextCtrlSummary->EndBold();
if ( !a_wsJobFileName.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( a_wsJobFileName );
}
m_richTextCtrlSummary->Newline();
}
// job file path
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Job File Path:\n") );
m_richTextCtrlSummary->EndBold();
if ( !a_wsJobFilePath.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( a_wsJobFilePath );
}
m_richTextCtrlSummary->Newline();
// source path
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Source Path:\n") );
m_richTextCtrlSummary->EndBold();
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_RESTORE_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
if ( !g_jobData.data[IEJ_SOURCE_PATHS].dataCurrent.wsVal.IsEmpty() )
{
wxStringTokenizer tokenizer(g_jobData.data[IEJ_SOURCE_PATHS].dataCurrent.wsVal, ";");
wxString wsToken; // set up to not have to trim last token's newline
while ( tokenizer.HasMoreTokens() )
{
wsToken += tokenizer.GetNextToken();
m_richTextCtrlSummary->WriteText( wsToken );
wsToken = _T("\n");
}
}
}
else // must be 'test
{
if ( !g_iniPrefs.data[IE_LAST_RESTORE_TARGET].dataCurrent.wsVal.IsEmpty() )
{
m_richTextCtrlSummary->WriteText(
g_iniPrefs.data[IE_LAST_RESTORE_TARGET].dataCurrent.wsVal );
}
}
// destination path
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_RESTORE_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
m_richTextCtrlSummary->Newline();
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Destination Path: ") );
m_richTextCtrlSummary->EndBold();
if ( !g_jobData.data[IEJ_DESTN_ROOT_PATH].dataCurrent.wsVal.IsEmpty() )
{
#if 1
wxString wsTest = g_jobData.data[IEJ_DESTN_ROOT_PATH].dataCurrent.wsVal;
ExpandPath( wsTest );
m_richTextCtrlSummary->WriteText( wsTest );
#else
m_richTextCtrlSummary->WriteText(
g_jobData.data[IEJ_DESTN_ROOT_PATH].dataCurrent.wsVal );
#endif
m_richTextCtrlSummary->Newline();
}
}
#if 0
// display the selected 'bag' size
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_RESTORE_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Selected Destination Size: ") );
m_richTextCtrlSummary->EndBold();
if ( g_jobData.data[IEJ_BAG_TYPE].dataCurrent.wsVal.IsEmpty() )
m_richTextCtrlSummary->WriteText(
g_jobData.data[IEJ_BAG_TYPE].dataDefault.wsVal );
else
m_richTextCtrlSummary->WriteText(
g_jobData.data[IEJ_BAG_TYPE].dataCurrent.wsVal );
m_richTextCtrlSummary->Newline();
}
#endif
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total Time: ") );
m_richTextCtrlSummary->EndBold();
if ( m_wsTotalTime.IsEmpty() )
{
wsT = _T("--:--:--");
}
else
{
wsT = m_wsTotalTime;
}
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
if ( !a_wsTimeBreakout.IsEmpty() )
{
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Times: ") );
m_richTextCtrlSummary->EndBold();
wsT = a_wsTimeBreakout;
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
}
// number of files
if ( m_szNTotalFiles )
wsT.Printf( _T("%Iu"), m_szNTotalFiles );
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total # of files: ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
// number of directories
if ( m_ulDirs )
wsT.Printf( _T("%ld"), m_ulDirs );
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total # of Directories: ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
// number of bags
if( m_ulBags )
wsT.Printf( _T("%ld"), m_ulBags );
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total # of 'Bags': ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
}
// bag size
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_RESTORE_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
wsT.Printf( _T("%s"),
g_jobData.data[IEJ_BAG_TYPE].dataCurrent.wsVal );
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("'Bag' size: ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
}
if ( (m_JobTypeInProgress == MY_BACKUP_JOB) ||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
// max path length
if ( m_ulMaxDestPathLen )
wsT.Printf( _T("%lu"), m_ulMaxDestPathLen );
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Max Dest'n Path Length ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( _("(max 511 chars): ") );
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
// .. and the path
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Longest Dest'n Path: ") );
m_richTextCtrlSummary->EndBold();
if ( !m_wsLongestDestPath.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( m_wsLongestDestPath );
}
else
{
m_richTextCtrlSummary->WriteText( _(" n/a") );
}
m_richTextCtrlSummary->Newline();
// max file name length
if ( m_ulMaxDestFileNameLen )
{
if ( m_ulMaxDestFileNameLen > 127 )
{
wsT.Printf( _T("%lu"), m_ulMaxDestFileNameLen,
m_ulMaxDestFileNameLen - 127);
wsT1.Printf( _T(" - + %d" ), m_ulMaxDestFileNameLen - 127 );
}
else
wsT.Printf( _T("%lu"), m_ulMaxDestFileNameLen );
}
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Max Dest'n File Name Length") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( _(" (max 127 chars): ") );
m_richTextCtrlSummary->WriteText( wsT );
if ( m_ulMaxDestFileNameLen > 127 )
{
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( wsT1 );
m_richTextCtrlSummary->EndBold();
}
m_richTextCtrlSummary->Newline();
// .. and the file name
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Longest Dest'n File Name: ") );
m_richTextCtrlSummary->EndBold();
if ( !m_wsLongestDestFileName.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( m_wsLongestDestFileName );
}
else
{
m_richTextCtrlSummary->WriteText( _(" n/a") );
}
m_richTextCtrlSummary->Newline();
}
#if 0
// max directory depth in source
wsT.Printf( _T("%u"), m_uiSrcDirLevelDepth );
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Max. Source directory depth: ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
#endif
// max directory depth in source
if ( (m_JobTypeInProgress == MY_BACKUP_JOB)||
(m_JobTypeInProgress == MY_JOB_TYPE_NONE) )
{
if ( m_uiZipDirLevelDepth )
wsT.Printf( _T("%u"), m_uiZipDirLevelDepth );
else
wsT = _(" n/a");
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Max. Destination directory depth: ") );
m_richTextCtrlSummary->EndBold();
m_richTextCtrlSummary->WriteText( wsT );
m_richTextCtrlSummary->Newline();
}
// total source size
FormatSize( (double)m_ullTotalZipsSize, wsT );
// wsT = CalculateSize( m_ullTotalSrcBytes );
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total Source Size: ") );
m_richTextCtrlSummary->EndBold();
if ( !wsT.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( wsT );
}
m_richTextCtrlSummary->Newline();
// total destination size
FormatSize( (double)m_ullTotalZipBytes, wsT );
// wsT = CalculateSize( m_ullTotalZipBytes );
m_richTextCtrlSummary->BeginBold();
m_richTextCtrlSummary->WriteText( _("Total Zip Size: ") );
m_richTextCtrlSummary->EndBold();
if ( !wsT.IsEmpty() )
{
m_richTextCtrlSummary->WriteText( wsT );
}
m_richTextCtrlSummary->Newline();
m_richTextCtrlSummary->EndAlignment();
m_richTextCtrlSummary->Newline();
m_richTextCtrlSummary->EndSuppressUndo();
m_richTextCtrlSummary->Thaw();
}
// ------------------------------- eof ------------------------------