javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/CheckDiskSpace.java
branchRCL_3
changeset 77 7cee158cb8cd
parent 24 0fd27995241b
child 78 71ad690e91f5
child 83 26b2b12093af
equal deleted inserted replaced
71:d5e927d5853b 77:7cee158cb8cd
    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 
       
    46         int initialSize = ball.iSuite.calculateInitialSize();
    45         int initialSize = ball.iSuite.calculateInitialSize();
    47         if (initialSize == 0 && ball.iJarFilename != null)
    46         int requiredSize = getRequiredSize(ball);
    48         {
       
    49             // Get initialSize from jar file size.
       
    50             initialSize = (int)FileUtils.getSize(ball.iJarFilename);
       
    51 
       
    52         }
       
    53         int requiredSize = initialSize + (100 * 1024); // +100kB
       
    54 
    47 
    55         if (ball.iUserConfirmation == null)
    48         if (ball.iUserConfirmation == null)
    56         {
    49         {
    57             // Before installation confirmation dialog is displayed,
    50             // Before installation confirmation dialog is displayed,
    58             // choose the default installation drive.
    51             // choose the default installation drive.
   101     {
    94     {
   102         // nop
    95         // nop
   103     }
    96     }
   104 
    97 
   105     /**
    98     /**
       
    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     /**
   106      * Checks if given drive has enough free disk space. Throws
   118      * Checks if given drive has enough free disk space. Throws
   107      * InstallerException if there is not enough free disk space.
   119      * InstallerException if there is not enough free disk space.
   108      */
   120      */
   109     private static void checkFreeSpace(int aSizeInBytes, int aDrive)
   121     private static void checkFreeSpace(int aSizeInBytes, int aDrive)
   110     {
   122     {
   137         {
   149         {
   138             DriveInfo drive = (DriveInfo)aDrives.elementAt(i);
   150             DriveInfo drive = (DriveInfo)aDrives.elementAt(i);
   139             int driveId = drive.getNumber();
   151             int driveId = drive.getNumber();
   140             if (SysUtil.isDiskSpaceBelowCriticalLevel(aSizeInBytes, driveId))
   152             if (SysUtil.isDiskSpaceBelowCriticalLevel(aSizeInBytes, driveId))
   141             {
   153             {
   142                 Log.logWarning("Drive " + driveId +
   154                 Log.log("Drive " + driveId +
   143                                " space below critical level, required space " +
   155                         " space below critical level, required space " +
   144                                aSizeInBytes + " bytes");
   156                         aSizeInBytes + " bytes");
   145             }
   157             }
   146             else
   158             else
   147             {
   159             {
   148                 Log.log("Drive " + driveId +
   160                 Log.log("Drive " + driveId +
   149                         " has enough free space, required space " +
   161                         " has enough free space, required space " +