|
|
1.1.1.3 root 1: /* The source code contained in this file has been derived from the source code
2: of Encryption for the Masses 2.02a by Paul Le Roux. Modifications and
1.1.1.5 ! root 3: additions to that source code contained in this file are Copyright (c) 2004-2005
1.1.1.4 root 4: TrueCrypt Foundation and Copyright (c) 2004 TrueCrypt Team. Unmodified
1.1.1.3 root 5: parts are Copyright (c) 1998-99 Paul Le Roux. This is a TrueCrypt Foundation
6: release. Please see the file license.txt for full license details. */
1.1 root 7:
8: #include "TCdefs.h"
9: #include "progress.h"
10: #include "../format/resource.h"
11:
12: extern HWND hCurPage;
13: extern HWND hProgressBar;
14: extern BOOL bThreadCancel;
15: extern int nPbar;
16:
1.1.1.3 root 17: ULONG prevTime, startTime;
18: __int64 totalSectors;
1.1 root 19:
20: void
1.1.1.3 root 21: InitProgressBar (__int64 totalSecs)
1.1 root 22: {
23: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
24: SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000);
25: SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
26:
27: prevTime = startTime = GetTickCount ();
28: totalSectors = totalSecs;
29: }
30:
31: BOOL
1.1.1.3 root 32: UpdateProgressBar (__int64 nSecNo)
1.1 root 33: {
34: char text[100];
35: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
36: int time = GetTickCount ();
1.1.1.4 root 37: unsigned __int64 bytesDone = (nSecNo+1) * SECTOR_SIZE;
1.1 root 38:
39: int elapsed = (time - startTime) / 1000;
40:
1.1.1.4 root 41: if (bytesDone < (unsigned __int64) BYTES_PER_MB * 10000000)
42: sprintf(text,"%I64d MB ", bytesDone / BYTES_PER_MB);
43: else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 10000000)
44: sprintf(text,"%I64d GB ", bytesDone / BYTES_PER_GB);
45: else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 10000000)
46: sprintf(text,"%I64d TB ", bytesDone / BYTES_PER_TB);
1.1.1.3 root 47: else
1.1.1.4 root 48: sprintf(text,"%I64d PB ", bytesDone / BYTES_PER_PB);
1.1.1.3 root 49:
1.1 root 50: SetWindowText (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text);
51:
1.1.1.3 root 52: if ((nSecNo+1) / 2 / 1024 / (1+elapsed) < 1024)
1.1.1.4 root 53: sprintf(text,"%I64d MB/s ", (nSecNo+1) / 2 / 1024 / (1+elapsed));
1.1.1.3 root 54: else
1.1.1.4 root 55: sprintf(text,"%I64d GB/s ", (nSecNo+1) / 2 / 1024 / 1024 / (1+elapsed));
1.1.1.3 root 56:
1.1 root 57: SetWindowText (GetDlgItem (hCurPage, IDC_WRITESPEED), text);
58:
59: if (nSecNo < totalSectors)
60: {
1.1.1.4 root 61: int sec = (int)((totalSectors - nSecNo) / ((nSecNo+1)/(elapsed+1)+1));
1.1.1.3 root 62:
1.1.1.4 root 63: if (sec >= 60 * 24 * 60)
64: sprintf(text,"%d days ", sec / (60 * 24 * 60));
65: else if (sec >= 120 * 60)
66: sprintf(text,"%d hours ", sec / (60 * 60));
67: else if (sec >= 120)
68: sprintf(text,"%d minutes ", sec / 60);
69: else if (sec >= 60)
70: sprintf(text,"%d minute ", sec / 60);
1.1.1.3 root 71: else
1.1.1.4 root 72: sprintf(text,"%d s ", sec);
1.1.1.3 root 73:
1.1 root 74: SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
75: }
76:
77: prevTime = time;
78:
79: SendMessage (hProgressBar, PBM_SETPOS, (int) (10000.0 * nSecNo / totalSectors), 0);
80:
81: return bThreadCancel;
82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.