Ignore:
Timestamp:
2018-04-19T20:37:16+02:00 (6 years ago)
Author:
Don-vip
Message:

see #16204 - Allow to start and close JOSM in WebStart sandbox mode (where every external access is denied). This was very useful to reproduce some very tricky bugs that occured in real life but were almost impossible to diagnose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r13487 r13647  
    2727import static java.awt.event.KeyEvent.VK_Z;
    2828import static org.openstreetmap.josm.tools.I18n.tr;
     29import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
     30import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
    2931import static org.openstreetmap.josm.tools.WinRegistry.HKEY_LOCAL_MACHINE;
    3032
     
    270272    @Override
    271273    public String getOSDescription() {
    272         return Utils.strip(System.getProperty("os.name")) + ' ' +
    273                 ((System.getenv("ProgramFiles(x86)") == null) ? "32" : "64") + "-Bit";
     274        return Utils.strip(getSystemProperty("os.name")) + ' ' +
     275                ((getSystemEnv("ProgramFiles(x86)") == null) ? "32" : "64") + "-Bit";
    274276    }
    275277
     
    316318            }
    317319            sb.append(" (").append(getCurrentBuild()).append(')');
    318         } catch (ReflectiveOperationException | JosmRuntimeException e) {
    319             Logging.error(e);
     320        } catch (ReflectiveOperationException | JosmRuntimeException | NoClassDefFoundError e) {
     321            Logging.log(Logging.LEVEL_ERROR, "Unable to get Windows build number", e);
     322            Logging.debug(e);
    320323        }
    321324        return sb.toString();
     
    473476    @Override
    474477    public File getDefaultCacheDirectory() {
    475         String p = System.getenv("LOCALAPPDATA");
     478        String p = getSystemEnv("LOCALAPPDATA");
    476479        if (p == null || p.isEmpty()) {
    477480            // Fallback for Windows OS earlier than Windows Vista, where the variable is not defined
    478             p = System.getenv("APPDATA");
     481            p = getSystemEnv("APPDATA");
    479482        }
    480483        return new File(new File(p, Main.pref.getJOSMDirectoryBaseName()), "cache");
     
    483486    @Override
    484487    public File getDefaultPrefDirectory() {
    485         return new File(System.getenv("APPDATA"), Main.pref.getJOSMDirectoryBaseName());
     488        return new File(getSystemEnv("APPDATA"), Main.pref.getJOSMDirectoryBaseName());
    486489    }
    487490
     
    524527            return;
    525528
    526         String javaLibPath = System.getProperty("java.home") + File.separator + "lib";
     529        String javaLibPath = getSystemProperty("java.home") + File.separator + "lib";
    527530        Path templateFile = FileSystems.getDefault().getPath(javaLibPath, templateFileName);
    528         if (!Files.isReadable(templateFile)) {
    529             Logging.warn("extended font config - unable to find font config template file {0}", templateFile.toString());
     531        String templatePath = templateFile.toString();
     532        if (templatePath.startsWith("null") || !Files.isReadable(templateFile)) {
     533            Logging.warn("extended font config - unable to find font config template file {0}", templatePath);
    530534            return;
    531535        }
     
    612616        // Use more low-level method to find the installed fonts.
    613617        List<String> fontsAvail = new ArrayList<>();
    614         Path fontPath = FileSystems.getDefault().getPath(System.getenv("SYSTEMROOT"), "Fonts");
     618        Path fontPath = FileSystems.getDefault().getPath(getSystemEnv("SYSTEMROOT"), "Fonts");
    615619        try (DirectoryStream<Path> ds = Files.newDirectoryStream(fontPath)) {
    616620            for (Path p : ds) {
Note: See TracChangeset for help on using the changeset viewer.