[SHLEXTDBG] Add utility to run / debug shell extensions.
[reactos.git] / modules / rosapps / applications / fraginator / Defragment.h
1 /*****************************************************************************
2
3 Defragment
4
5 *****************************************************************************/
6
7
8 #ifndef DEFRAGMENT_H
9 #define DEFRAGMENT_H
10
11
12 #include "Unfrag.h"
13 #include "DriveVolume.h"
14 #include "Mutex.h"
15
16
17 extern int FitName (wchar_t *destination, const wchar_t *path, const wchar_t *filename, uint32 totalWidth);
18
19
20 typedef struct DefragReport
21 {
22 wstring RootPath;
23 uint64 DiskSizeBytes;
24 uint64 DirsCount;
25 uint64 FilesCount;
26 uint64 FilesSizeBytes;
27 uint64 FilesSizeOnDisk;
28 uint64 FilesSizeClusters;
29 uint64 FilesSlackBytes;
30 uint32 FilesFragments;
31 double AverageFragments; // = FilesFragments / FilesCount
32 double PercentFragged;
33 double PercentSlack;
34
35 vector<uint32> FraggedFiles;
36 vector<uint32> UnfraggedFiles;
37 vector<uint32> UnmovableFiles;
38 } DefragReport;
39
40
41 class Defragment
42 {
43 public:
44 Defragment (wstring Name, DefragType DefragMethod);
45 ~Defragment ();
46
47 // Commands
48 void Start (void);
49 void TogglePause (void);
50 void Stop (void);
51
52 // Info
53 bool IsDoneYet (void);
54 bool HasError (void);
55 wstring GetStatusString (void);
56 double GetStatusPercent (void);
57 DefragType GetDefragType (void) { return (Method); }
58 DefragReport &GetDefragReport (void) { return (Report); }
59 DriveVolume &GetVolume (void) { return (Volume); }
60
61 // Mutex
62 void Lock (void) { DefragMutex.Lock (); }
63 void Unlock (void) { DefragMutex.Unlock (); }
64
65 // Limit length of status string to 70 chars?
66 bool GetDoLimitLength (void) { return (DoLimitLength); }
67 void SetDoLimitLength (bool L) { DoLimitLength = L; }
68
69 private:
70 void FastDefrag (void);
71 void ExtensiveDefrag (void);
72 void SetStatusString (wstring NewStatus);
73
74 DWORD LastBMPUpdate; // Last time volume bitmap was updated
75 DefragReport Report;
76 bool DoLimitLength;
77 DefragType Method;
78 wstring DriveName;
79 DriveVolume Volume;
80 wstring StatusString;
81 wstring ErrorString;
82 double StatusPercent;
83 Mutex DefragMutex;
84 bool Error;
85 bool Done;
86 bool PleaseStop;
87 bool PleasePause;
88 DefragType DefragMethod;
89 };
90
91
92 #endif // DEFRAGMENT_H