javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/CheckDiskSpace.java
equal
deleted
inserted
replaced
40 public class CheckDiskSpace extends ExeStep |
40 public class CheckDiskSpace extends ExeStep |
41 { |
41 { |
42 public void execute(ExeBall aBall) |
42 public void execute(ExeBall aBall) |
43 { |
43 { |
44 InstallBall ball = (InstallBall)aBall; |
44 InstallBall ball = (InstallBall)aBall; |
|
45 |
45 int initialSize = ball.iSuite.calculateInitialSize(); |
46 int initialSize = ball.iSuite.calculateInitialSize(); |
46 int requiredSize = getRequiredSize(ball); |
47 if (initialSize == 0 && ball.iJarFilename != null) |
|
48 { |
|
49 // Get initialSize from jar file size. |
|
50 initialSize = (int)FileUtils.getSize(ball.iJarFilename); |
|
51 |
|
52 } |
|
53 int requiredSize = initialSize + (100 * 1024); // +100kB |
47 |
54 |
48 if (ball.iUserConfirmation == null) |
55 if (ball.iUserConfirmation == null) |
49 { |
56 { |
50 // Before installation confirmation dialog is displayed, |
57 // Before installation confirmation dialog is displayed, |
51 // choose the default installation drive. |
58 // choose the default installation drive. |
94 { |
101 { |
95 // nop |
102 // nop |
96 } |
103 } |
97 |
104 |
98 /** |
105 /** |
99 * Returns amount of disk space this application requires. |
|
100 */ |
|
101 static int getRequiredSize(InstallBall aBall) |
|
102 { |
|
103 int initialSize = aBall.iSuite.getInitialSize(); |
|
104 if (initialSize <= 0) |
|
105 { |
|
106 initialSize = aBall.iSuite.calculateInitialSize(); |
|
107 } |
|
108 if (initialSize == 0 && aBall.iJarFilename != null) |
|
109 { |
|
110 // Get initialSize from jar file size. |
|
111 initialSize = (int)FileUtils.getSize(aBall.iJarFilename); |
|
112 |
|
113 } |
|
114 return initialSize + (100 * 1024); // +100kB |
|
115 } |
|
116 |
|
117 /** |
|
118 * Checks if given drive has enough free disk space. Throws |
106 * Checks if given drive has enough free disk space. Throws |
119 * InstallerException if there is not enough free disk space. |
107 * InstallerException if there is not enough free disk space. |
120 */ |
108 */ |
121 private static void checkFreeSpace(int aSizeInBytes, int aDrive) |
109 private static void checkFreeSpace(int aSizeInBytes, int aDrive) |
122 { |
110 { |
149 { |
137 { |
150 DriveInfo drive = (DriveInfo)aDrives.elementAt(i); |
138 DriveInfo drive = (DriveInfo)aDrives.elementAt(i); |
151 int driveId = drive.getNumber(); |
139 int driveId = drive.getNumber(); |
152 if (SysUtil.isDiskSpaceBelowCriticalLevel(aSizeInBytes, driveId)) |
140 if (SysUtil.isDiskSpaceBelowCriticalLevel(aSizeInBytes, driveId)) |
153 { |
141 { |
154 Log.log("Drive " + driveId + |
142 Log.logWarning("Drive " + driveId + |
155 " space below critical level, required space " + |
143 " space below critical level, required space " + |
156 aSizeInBytes + " bytes"); |
144 aSizeInBytes + " bytes"); |
157 } |
145 } |
158 else |
146 else |
159 { |
147 { |
160 Log.log("Drive " + driveId + |
148 Log.log("Drive " + driveId + |
161 " has enough free space, required space " + |
149 " has enough free space, required space " + |