diff options
Diffstat (limited to 'src/Common/Progress.c')
-rw-r--r-- | src/Common/Progress.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/Common/Progress.c b/src/Common/Progress.c index afa6f645..89697a62 100644 --- a/src/Common/Progress.c +++ b/src/Common/Progress.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include "../Format/FormatCom.h" | 17 | #include "../Format/FormatCom.h" |
18 | #include "../Format/resource.h" | 18 | #include "../Format/resource.h" |
19 | 19 | ||
20 | #include <Strsafe.h> | ||
21 | |||
20 | static ULONG prevTime, startTime; | 22 | static ULONG prevTime, startTime; |
21 | static __int64 TotalSize; | 23 | static __int64 TotalSize; |
22 | static __int64 resumedPointBytesDone; | 24 | static __int64 resumedPointBytesDone; |
@@ -74,31 +76,31 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) | |||
74 | double perc = (double) (100.0 * (bProgressBarReverse ? ((double) (TotalSize - byteOffset)) : ((double) byteOffset)) / (TotalSize == 0 ? 0.0001 : ((double) TotalSize))); | 76 | double perc = (double) (100.0 * (bProgressBarReverse ? ((double) (TotalSize - byteOffset)) : ((double) byteOffset)) / (TotalSize == 0 ? 0.0001 : ((double) TotalSize))); |
75 | 77 | ||
76 | if (perc > 99.999999999) | 78 | if (perc > 99.999999999) |
77 | wcscpy (text, GetString ("PROCESSED_PORTION_100_PERCENT")); | 79 | StringCbCopyW (text,sizeof(text), GetString ("PROCESSED_PORTION_100_PERCENT")); |
78 | else | 80 | else |
79 | _snwprintf (text, sizeof text/2, GetString ("PROCESSED_PORTION_X_PERCENT"), perc); | 81 | StringCbPrintfW (text, sizeof text, GetString ("PROCESSED_PORTION_X_PERCENT"), perc); |
80 | 82 | ||
81 | wcscat (speed, L" "); | 83 | StringCbCatW (speed, sizeof(speed), L" "); |
82 | } | 84 | } |
83 | else | 85 | else |
84 | { | 86 | { |
85 | GetSizeString (bytesDone, text); | 87 | GetSizeString (bytesDone, text, sizeof(text)); |
86 | if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000) | 88 | if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000) |
87 | swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB")); | 89 | StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB")); |
88 | else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000) | 90 | else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000) |
89 | swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB")); | 91 | StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB")); |
90 | else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000) | 92 | else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000) |
91 | swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB")); | 93 | StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB")); |
92 | else | 94 | else |
93 | swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB")); | 95 | StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB")); |
94 | } | 96 | } |
95 | 97 | ||
96 | SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text); | 98 | SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text); |
97 | 99 | ||
98 | if (!bShowStatus) | 100 | if (!bShowStatus) |
99 | { | 101 | { |
100 | GetSpeedString (bRWThroughput ? bytesPerSec*2 : bytesPerSec, speed); | 102 | GetSpeedString (bRWThroughput ? bytesPerSec*2 : bytesPerSec, speed, sizeof(speed)); |
101 | wcscat (speed, L" "); | 103 | StringCbCatW (speed, sizeof(speed), L" "); |
102 | SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed); | 104 | SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed); |
103 | } | 105 | } |
104 | 106 | ||
@@ -107,15 +109,15 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) | |||
107 | int64 sec = (int64) ((bProgressBarReverse ? byteOffset : (TotalSize - byteOffset)) / (bytesPerSec == 0 ? 0.001 : bytesPerSec)); | 109 | int64 sec = (int64) ((bProgressBarReverse ? byteOffset : (TotalSize - byteOffset)) / (bytesPerSec == 0 ? 0.001 : bytesPerSec)); |
108 | 110 | ||
109 | if (bytesPerSec == 0 || sec > 60 * 60 * 24 * 999) | 111 | if (bytesPerSec == 0 || sec > 60 * 60 * 24 * 999) |
110 | swprintf (text, L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE")); | 112 | StringCbPrintfW (text, sizeof(text), L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE")); |
111 | else if (sec >= 60 * 60 * 24 * 2) | 113 | else if (sec >= 60 * 60 * 24 * 2) |
112 | swprintf (text, L"%I64d %s ", sec / (60 * 24 * 60), days); | 114 | StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / (60 * 24 * 60), days); |
113 | else if (sec >= 120 * 60) | 115 | else if (sec >= 120 * 60) |
114 | swprintf (text, L"%I64d %s ", sec / (60 * 60), hours); | 116 | StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / (60 * 60), hours); |
115 | else if (sec >= 120) | 117 | else if (sec >= 120) |
116 | swprintf (text, L"%I64d %s ", sec / 60, minutes); | 118 | StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / 60, minutes); |
117 | else | 119 | else |
118 | swprintf (text, L"%I64d %s ", sec, seconds); | 120 | StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec, seconds); |
119 | 121 | ||
120 | SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text); | 122 | SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text); |
121 | } | 123 | } |