javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/FileRoots.java
branchRCL_3
changeset 19 04becd199f91
child 56 abc41079b313
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package com.nokia.mj.impl.installer.utils;
       
    20 
       
    21 public class FileRoots
       
    22 {
       
    23 
       
    24     private static int iResourceDriveNumber = -1;
       
    25 
       
    26     /**
       
    27      * Returns string describing current platform.
       
    28      */
       
    29     public static String getPlatform()
       
    30     {
       
    31         return "s60";
       
    32     }
       
    33 
       
    34     /**
       
    35      * Returns the directory that contains the Java applications
       
    36      * to be preinstalled in S60.
       
    37      */
       
    38     public static String getPreinstallDir()
       
    39     {
       
    40         return "\\resource\\java\\preinstall\\";
       
    41     }
       
    42 
       
    43     /**
       
    44      * Returns preinstallation drive for given filename.
       
    45      * Filename must contain full path including drive letter.
       
    46      */
       
    47     public static int getPreinstallDrive(String aFilename)
       
    48     {
       
    49         int drive = FileUtils.getDrive(aFilename);
       
    50         if (SysUtil.isDriveReadOnly(drive))
       
    51         {
       
    52             // if the drive is ReadOnly drive (e.g. Z:),
       
    53             // use system default installation drive (usually C:)
       
    54             drive = SysUtil.getDefaultPhoneMemory();
       
    55         }
       
    56         return drive;
       
    57     }
       
    58 
       
    59     /**
       
    60      * Returns directory where the icons registered to
       
    61      * platform should be copied in S60.
       
    62      */
       
    63     public static String getRegisteredIconDir(int aDrive)
       
    64     {
       
    65         return FileUtils.getDriveName(aDrive) + ":\\data\\java\\";
       
    66     }
       
    67 
       
    68     /**
       
    69      * Returns the directory that contains the resources
       
    70      * needed by Java Installer, e.g. 'trusted' icon
       
    71      */
       
    72     public static String getResourceDir()
       
    73     {
       
    74         return FileUtils.setDrive(
       
    75                    System.getProperty("JAVA_RES_ROOT"), getResourceDrive());
       
    76     }
       
    77 
       
    78     /**
       
    79      * Returns root folder for MIDP runtime in S60.
       
    80      */
       
    81     public static String getMidpRoot()
       
    82     {
       
    83         int resourceDrive = getResourceDrive();
       
    84         if (resourceDrive == 25)
       
    85         {
       
    86             // If MIDP is installed to Z: drive,
       
    87             // use C: drive as MIDP root.
       
    88             resourceDrive = 2;
       
    89         }
       
    90         String midpRoot = _getMidpRoot();
       
    91         return ((char)(resourceDrive + 'A')) + ":" + midpRoot;
       
    92     }
       
    93 
       
    94     /**
       
    95      * Returns root folder for applications in S60.
       
    96      */
       
    97     static String getAppsRoot()
       
    98     {
       
    99         // Note that drive letter does not matter here,
       
   100         // installer will replace it with correct one.
       
   101         return getMidpRoot() + "apps\\";
       
   102     }
       
   103 
       
   104     /**
       
   105      * Returns installer root folder in S60.
       
   106      */
       
   107     static String getInstallerRoot()
       
   108     {
       
   109         return getMidpRoot() + "installer\\";
       
   110     }
       
   111 
       
   112     /**
       
   113      * Returns the drive where OMJ was installed.
       
   114      */
       
   115     private static int getResourceDrive()
       
   116     {
       
   117         if (iResourceDriveNumber == -1)
       
   118         {
       
   119             iResourceDriveNumber = _getResourceDrive();
       
   120         }
       
   121         return iResourceDriveNumber;
       
   122     }
       
   123 
       
   124     /*** ----------------------------- NATIVE ----------------------------- */
       
   125 
       
   126     /**
       
   127      * Returns the drive number of the drive where the installer resources are.
       
   128      * In case of error logs the error and returns default drive number
       
   129      * that can be build specific but that is usually 2 (C: drive)
       
   130      *
       
   131      * @return the drive (0..25) where the installer resources are
       
   132      */
       
   133     private static native int _getResourceDrive();
       
   134 
       
   135     /**
       
   136      * Returns the path (without drive letter) to the MIDP runtime directory,
       
   137      * for example \private\102033E6\
       
   138      *
       
   139      * @return root directory where OMJ binary has been installed to
       
   140      */
       
   141     private static native String _getMidpRoot();
       
   142 }