javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CLDCCompatibilityDelegate.java
changeset 78 71ad690e91f5
parent 21 2a9601315dfc
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
    40             throw new IOException(e.getMessage());
    40             throw new IOException(e.getMessage());
    41         }
    41         }
    42         return inputStream;
    42         return inputStream;
    43     }
    43     }
    44 
    44 
    45     public String convertPathToSpecific(String path) {
    45     public String convertPathToSpecific(String path) {        
    46         String jsr75Path = path;
    46         String res = path;
    47         if (!jsr75Path.startsWith("file:///")) {
    47         
    48             // In JSR 75 the file separator is '/' and not '\'
    48         // In JSR 75 the file separator is '/' and not '\'
    49             jsr75Path = jsr75Path.replace('\\', '/');
    49         res = res.replace('\\', '/');
    50             jsr75Path = "file:///" + jsr75Path;
    50         
       
    51         if (res.startsWith("file:///")) {
       
    52             res = res.substring(8);
    51         }
    53         }
    52         
    54         
    53         return jsr75Path;
    55         boolean hasDrive = false;
    54     }
    56         if (res.length() >= 2) {
       
    57             char drive = res.charAt(0);
       
    58             hasDrive = ((drive >= 'A' && drive <= 'Z') || (drive >= 'a' && drive <= 'z')) 
       
    59                 && (res.charAt(1) == ':');
       
    60         }
    55 
    61 
    56     public String convertPathFromSpecific(String jsr75Path) {
    62         if (!hasDrive) {
    57         String stdPath = jsr75Path;
    63             res = System.getProperty("fileconn.dir.private") + res; // may start now as file:///
    58         if (jsr75Path.startsWith("file:///")) {
       
    59             stdPath = stdPath.replace('/', '\\');
       
    60             stdPath = stdPath.substring(8, stdPath.length()).replace('/', '\\');;
       
    61         }
    64         }
    62         return stdPath;
    65 
       
    66         if (!res.startsWith("file:///")) {
       
    67             res = "file:///" + res;
       
    68         }
       
    69         
       
    70         // The format now should be: file:///<drive>:/<path>
       
    71         
       
    72         return res;
    63     }
    73     }
    64     
    74     
    65     public boolean canOpenFile(String path) throws SecurityException {
    75     public boolean canOpenFile(String path) throws SecurityException {
    66         String jsr75Path = convertPathToSpecific(path);
    76         String jsr75Path = convertPathToSpecific(path);
    67         try {
    77         try {