javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/ConfirmInstallation.java
changeset 76 4ad59aaee882
parent 23 98ccebc37403
child 78 71ad690e91f5
child 83 26b2b12093af
--- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/ConfirmInstallation.java	Thu Sep 02 20:20:40 2010 +0300
+++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/ConfirmInstallation.java	Fri Sep 17 08:28:21 2010 +0300
@@ -126,6 +126,7 @@
         installInfo.setDriveId(ball.iInstallationDrive);
         Vector drives = new Vector();
         SysUtil.getUserVisibleDrives(drives);
+        removeFullDrives(ball, drives);
         int[] driveIds = new int[drives.size()];
         int[] driveTypes = new int[drives.size()];
         long[] driveFreeSpaces = new long[drives.size()];
@@ -385,4 +386,34 @@
         }
         return size;
     }
+
+    /**
+     * Removes drives which do not have enough free space for the
+     * application from the aDrives vector.
+     */
+    private void removeFullDrives(InstallBall aBall, Vector aDrives)
+    {
+        int requiredSize = CheckDiskSpace.getRequiredSize(aBall);
+        for (int i = 0; i < aDrives.size(); i++)
+        {
+            DriveInfo drive = (DriveInfo)aDrives.elementAt(i);
+            int driveId = drive.getNumber();
+            if (SysUtil.isDiskSpaceBelowCriticalLevel(requiredSize, driveId))
+            {
+                Log.logWarning("Drive " + FileUtils.getDriveName(driveId) +
+                               " (" + driveId + ") does not have enough " +
+                               " free space, required space " + requiredSize +
+                               " bytes");
+                aDrives.removeElementAt(i);
+                i--; // Decrease index because drive was removed from Vector.
+            }
+        }
+        if (aDrives.size() == 0)
+        {
+            // None of the available drives has enough space,
+            // throw an exception.
+            throw InstallerException.getOutOfDiskSpaceException(
+                requiredSize, null);
+        }
+    }
 }