1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jdiagnose.library.io;
17
18 import org.jdiagnose.DiagnosticUnit;
19
20 /***
21 * @author jmccrindle
22 */
23 public class Win32DiskSpaceDiagnostic extends DiagnosticUnit {
24
25 private long minimumFreeSpaceBytes = 0L;
26 private String drive = null;
27
28 public void diagnoseFreeSpace() {
29 assertNotNull("drive property must be set", drive);
30 String os = System.getProperty("os.name").toLowerCase();
31 assertTrue("Operating System not part of the Microsoft Windows Family (" + os + ")",
32 (os.indexOf("windows 9") > -1)
33 || (os.indexOf("nt") > -1)
34 || (os.indexOf("windows 2000") > -1)
35 || (os.indexOf("windows xp") > -1));
36 long diskFreeSpace = Win32Utils.getDiskFreeSpace(drive);
37 assertTrue("Free Disk Space is less than minimum space required (" + diskFreeSpace + ")", diskFreeSpace > minimumFreeSpaceBytes);
38 }
39
40 /***
41 * @return Returns the drive.
42 */
43 public String getDrive() {
44 return drive;
45 }
46 /***
47 * @param drive The drive to set.
48 */
49 public void setDrive(String drive) {
50 this.drive = drive;
51 }
52 /***
53 * @return Returns the minimumFreeSpaceBytes.
54 */
55 public long getMinimumFreeSpaceBytes() {
56 return minimumFreeSpaceBytes;
57 }
58 /***
59 * @param minimumFreeSpaceBytes The minimumFreeSpaceBytes to set.
60 */
61 public void setMinimumFreeSpaceBytes(long minimumFreeSpaceBytes) {
62 this.minimumFreeSpaceBytes = minimumFreeSpaceBytes;
63 }
64 }