ReactOS 0.4.16-dev-122-g325d74c
ReportDialog.cpp File Reference
#include "ReportDialog.h"
#include "Unfrag.h"
#include "Fraginator.h"
#include "DriveVolume.h"
#include "Defragment.h"
#include "resource.h"
Include dependency graph for ReportDialog.cpp:

Go to the source code of this file.

Functions

void SetReportInfo (HWND Dlg, DefragReport &Report, uint32 BytesDivisor, const wchar_t *BytesUnits, bool Fractional)
 
INT_PTR CALLBACK ReportDialogProc (HWND Dlg, UINT Msg, WPARAM WParam, LPARAM LParam)
 

Function Documentation

◆ ReportDialogProc()

INT_PTR CALLBACK ReportDialogProc ( HWND  Dlg,
UINT  Msg,
WPARAM  WParam,
LPARAM  LParam 
)

Definition at line 197 of file ReportDialog.cpp.

198{
199 switch (Msg)
200 {
201 case WM_INITDIALOG:
202 SetReportInfo (Dlg, Defrag->GetDefragReport (), 1, L"bytes", false);
203 return (1);
204
205 case WM_COMMAND:
206 switch (LOWORD(WParam))
207 {
208 case IDC_REPORTOK:
209 EndDialog (Dlg, 0);
210 return (1);
211
212 case IDC_GIGABYTES:
213 SetReportInfo (Dlg, Defrag->GetDefragReport (), 1024*1024*1024, L"GB", true);
214 return (1);
215
216 case IDC_MEGABYTES:
217 SetReportInfo (Dlg, Defrag->GetDefragReport (), 1024*1024, L"MB", false);
218 return (1);
219
220 case IDC_KILOBYTES:
221 SetReportInfo (Dlg, Defrag->GetDefragReport (), 1024, L"KB", false);
222 return (1);
223
224 case IDC_BYTES:
225 SetReportInfo (Dlg, Defrag->GetDefragReport (), 1, L"bytes", false);
226 return (1);
227 }
228 }
229
230 return (0);
231}
Defragment * Defrag
Definition: Fraginator.cpp:20
void SetReportInfo(HWND Dlg, DefragReport &Report, uint32 BytesDivisor, const wchar_t *BytesUnits, bool Fractional)
Definition: ReportDialog.cpp:9
DefragReport & GetDefragReport(void)
Definition: Defragment.h:58
struct @1636 Msg[]
#define IDC_BYTES
Definition: resource.h:26
#define IDC_MEGABYTES
Definition: resource.h:35
#define IDC_GIGABYTES
Definition: resource.h:33
#define IDC_REPORTOK
Definition: resource.h:19
#define IDC_KILOBYTES
Definition: resource.h:27
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by MainDialogProc().

◆ SetReportInfo()

void SetReportInfo ( HWND  Dlg,
DefragReport Report,
uint32  BytesDivisor,
const wchar_t BytesUnits,
bool  Fractional 
)

Definition at line 9 of file ReportDialog.cpp.

10{
11 wchar_t Text[1000];
12 wchar_t Text2[1000];
13 wchar_t Text3[1000];
14
15 memset (Text, 0, sizeof (Text));
16
17 // Volume name
18 SetDlgItemText (Dlg, IDC_DRIVELETTER, Report.RootPath.c_str());
19
20 // Volume label
22
23 // Volume Serial
25
26 // File System
28
29 // DiskSizeBytes
30 if (Fractional)
31 {
32 swprintf (Text, L"%.2f %s", (double)(signed)(Report.DiskSizeBytes /
33 (BytesDivisor / 1024)) / 1024.0, BytesUnits);
34 }
35 else
36 {
37 AddCommas (Text, Report.DiskSizeBytes / BytesDivisor);
38 wcscat (Text, L" ");
39 wcscat (Text, BytesUnits);
40 }
41
43
44 // DiskFreeBytes
45 if (Fractional)
46 {
47 swprintf (Text, L"%.2f %s", (double)(signed)(Defrag->GetVolume().GetVolumeInfo().FreeBytes /
48 (BytesDivisor / 1024)) / 1024.0, BytesUnits);
49 }
50 else
51 {
53 wcscat (Text, L" ");
54 wcscat (Text, BytesUnits);
55 }
57
58 // DiskSizeClusters
60 wcscat (Text, L" clusters");
62
63 // DiskClusterSize
66
67 // DirsCount
68 AddCommas (Text, Report.DirsCount);
70
71 // FilesCount
72 AddCommas (Text, Report.FilesCount);
74
75 // FilesFragged
76 swprintf (Text, L"(%.2f%%)", Report.PercentFragged);
77 AddCommas (Text2, Report.FraggedFiles.size());
78 swprintf (Text3, L"%s %s", Text, Text2);
79 SetDlgItemText (Dlg, IDC_FILESFRAGGED, Text3);
80
81 // Average Frags
82 swprintf (Text, L"%.2f", Report.AverageFragments);
84
85 // FilesSizeBytes
86 if (Fractional)
87 {
88 swprintf (Text, L"%.2f %s", (double)(signed)(Report.FilesSizeBytes /
89 (BytesDivisor / 1024)) / 1024.0, BytesUnits);
90 }
91 else
92 {
93 AddCommas (Text, Report.FilesSizeBytes / (uint64)BytesDivisor);
94 wcscat (Text, L" ");
95 wcscat (Text, BytesUnits);
96 }
98
99 // Files SizeOnDisk
100 if (Fractional)
101 {
102 swprintf (Text, L"%.2f %s", (double)(signed)((Report.FilesSizeBytes + Report.FilesSlackBytes) /
103 (BytesDivisor / 1024)) / 1024.0, BytesUnits);
104 }
105 else
106 {
107 AddCommas (Text, (Report.FilesSizeBytes + Report.FilesSlackBytes) / (uint64)BytesDivisor);
108 wcscat (Text, L" ");
109 wcscat (Text, BytesUnits);
110
111 }
113
114 // FilesSlackBytes
115 if (Fractional)
116 {
117 swprintf (Text, L"%.2f %s", (double)(signed)(Report.FilesSlackBytes /
118 (BytesDivisor / 1024)) / 1024.0, BytesUnits);
119 }
120 else
121 {
122 AddCommas (Text, Report.FilesSlackBytes / BytesDivisor);
123 wcscat (Text, L" ");
124 wcscat (Text, BytesUnits);
125 }
126 swprintf (Text2, L"(%.2f%%)", Report.PercentSlack);
127 swprintf (Text3, L"%s %s", Text2, Text);
129
130 // Recommendation
131 bool PFRec = false; // Recommend based off percent fragged files?
132 bool AFRec = false; // Recommend based off average fragments per file?
133
134 if (Report.PercentFragged >= 5.0f)
135 PFRec = true;
136
137 if (Report.AverageFragments >= 1.1f)
138 AFRec = true;
139
140 wcscpy (Text, L"* ");
141
142 if (PFRec)
143 {
145 (
146 Text2,
147 L"%.2f%% of the files on this volume are fragmented. ",
148 Report.PercentFragged
149 );
150
151 wcscat (Text, Text2);
152 }
153
154 if (AFRec)
155 {
157 (
158 Text2,
159 L"The average fragments per file (%.2f) indicates a high degree of fragmentation. ",
160 Report.AverageFragments
161 );
162
163 wcscat (Text, Text2);
164 }
165
166 if (Report.PercentFragged < 5.0f && Report.AverageFragments < 1.1f)
167 swprintf (Text, L"* No defragmentation is necessary at this point.");
168 else
169 if (Report.PercentFragged < 15.0f && Report.AverageFragments < 1.3f)
170 wcscat (Text, L"It is recommended that you perform a Fast Defrag.");
171 else
172 wcscat (Text, L"It is recommended that you perform an Extensive Defrag.");
173
174 // Should we recommend a smaller cluster size?
175 if (Report.PercentSlack >= 10.0f)
176 {
178 (
179 Text2,
180 L"\n* A large amount of disk space (%.2f%%) is being lost "
181 L"due to a large (%u bytes) cluster size. It is recommended "
182 L"that you use a disk utility such as Partition Magic to "
183 L"reduce the cluster size of this volume.",
184 Report.PercentSlack,
186 );
187
188 wcscat (Text, Text2);
189 }
190
192
193 return;
194}
wchar_t * AddCommas(wchar_t *Result, uint64 Number)
Definition: Unfrag.cpp:48
DriveVolume & GetVolume(void)
Definition: Defragment.h:59
VolumeInfo GetVolumeInfo(void)
Definition: DriveVolume.h:109
char * Text
Definition: combotst.c:136
#define swprintf
Definition: precomp.h:40
unsigned long long uint64
Definition: platform.h:18
#define IDC_VOLUMELABEL
Definition: resource.h:24
#define IDC_RECOMMEND
Definition: resource.h:28
#define IDC_DRIVELETTER
Definition: resource.h:18
#define IDC_DISKSIZECLUSTERS
Definition: resource.h:20
#define IDC_VOLUMESERIAL
Definition: resource.h:25
#define IDC_DISKFREEBYTES
Definition: resource.h:34
#define IDC_FILESYSTEM
Definition: resource.h:22
#define IDC_FILESSLACKBYTES
Definition: resource.h:32
#define IDC_FILESSIZEBYTES
Definition: resource.h:30
#define IDC_FILESSIZEONDISK
Definition: resource.h:31
#define IDC_DISKCLUSTERSIZE
Definition: resource.h:21
#define IDC_DIRSCOUNT
Definition: resource.h:37
#define IDC_FILESFRAGGED
Definition: resource.h:36
#define IDC_FILESCOUNT
Definition: resource.h:29
#define IDC_AVERAGEFRAGS
Definition: resource.h:38
#define IDC_DISKSIZEBYTES
Definition: resource.h:17
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memset(x, y, z)
Definition: compat.h:39
double PercentSlack
Definition: Defragment.h:33
double PercentFragged
Definition: Defragment.h:32
vector< uint32 > FraggedFiles
Definition: Defragment.h:35
uint64 FilesSlackBytes
Definition: Defragment.h:29
uint64 FilesCount
Definition: Defragment.h:25
wstring RootPath
Definition: Defragment.h:22
uint64 FilesSizeBytes
Definition: Defragment.h:26
uint64 DirsCount
Definition: Defragment.h:24
double AverageFragments
Definition: Defragment.h:31
uint64 DiskSizeBytes
Definition: Defragment.h:23
wstring Name
Definition: DriveVolume.h:68
wstring Serial
Definition: DriveVolume.h:69
uint64 ClusterCount
Definition: DriveVolume.h:72
uint64 FreeBytes
Definition: DriveVolume.h:75
wstring FileSystem
Definition: DriveVolume.h:71
uint32 ClusterSize
Definition: DriveVolume.h:73
#define SetDlgItemText
Definition: winuser.h:5861

Referenced by ReportDialogProc().