Changeset 441


Ignore:
Timestamp:
Nov 25, 2014, 12:53:27 AM (11 years ago)
Author:
dmik
Message:

icedtea-web: Update platform-dependent code branching logic.

This also takes 1.5 PD-related changes into account on OS/2.

Location:
trunk/icedtea-web/netx/net/sourceforge/jnlp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java

    r429 r441  
    6666
    6767        String configPath = System.getProperty("user.home") + File.separator
    68                 + (Defaults.OS_DOS_LIKE ? "Mozilla" : ".mozilla")
     68                + (JNLPRuntime.OS_DOS_LIKE ? "Mozilla" : ".mozilla")
    6969                + File.separator + "firefox" + File.separator;
    7070
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/config/Defaults.java

    r429 r441  
    8181
    8282    /**
    83      * Whether the OS is a DOS-like (Windows, OS/2) or not.
    84      */
    85     public static final boolean OS_DOS_LIKE =
    86         System.getProperty("os.name").startsWith("OS/2") ||
    87         System.getProperty("os.name").contains("Windows");
    88 
    89     /**
    9083     * Get the default settings for deployment
    9184     */
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java

    r429 r441  
    761761
    762762    /**
    763      * @return {@code true} if running on Windows
    764      */
    765     public static boolean isWindows() {
     763     * Set to {@code true} if running on Windows.
     764     */
     765    public static final boolean OS_WIN;
     766
     767    /**
     768     * Set to {@code true} if running on OS/2.
     769     */
     770    public static final boolean OS_OS2;
     771
     772    static {
    766773        String os = System.getProperty("os.name");
    767         return (os != null && os.startsWith("Windows"));
    768     }
    769 
    770     /**
    771      * @return {@code true} if running on a Unix or Unix-like system (including
    772      * Linux and *BSD)
    773      */
    774     public static boolean isUnix() {
    775         String sep = System.getProperty("file.separator");
    776         return (sep != null && sep.equals("/"));
    777     }
     774        OS_WIN = os != null && System.getProperty("os.name").startsWith("Windows");
     775        OS_OS2 = os != null && System.getProperty("os.name").startsWith("OS/2");
     776    }
     777
     778    /**
     779     * Set to {@code true} if running on Windows or OS/2.
     780     */
     781    public static final boolean OS_DOS_LIKE = OS_WIN || OS_OS2;
     782
     783    /**
     784     * Set to {@code true} if running on Unix or Unix-like system (including
     785     * Linux and *BSD). This is pretty much dumb ATM as it simply negates OS_DOS but it's not
     786     * dumbier than the method used before (based on 'file.separator' equal to '/').
     787     */
     788    public static final boolean OS_UNIX_LIKE = !OS_DOS_LIKE;
    778789
    779790    public static void setInitialArgments(List<String> args) {
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/services/XBasicService.java

    r429 r441  
    201201     */
    202202    private void initializeBrowserCommand() {
    203         if (JNLPRuntime.isWindows()) {
     203        if (JNLPRuntime.OS_WIN) {
    204204            command = "rundll32 url.dll,FileProtocolHandler ";
    205         } else if (JNLPRuntime.isUnix()) {
     205        } else if (JNLPRuntime.OS_UNIX_LIKE) {
    206206            DeploymentConfiguration config = JNLPRuntime.getConfiguration();
    207207            command = config.getProperty(DeploymentConfiguration.KEY_BROWSER_PATH);
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/util/FileUtils.java

    r429 r441  
    217217        }
    218218
    219         if (JNLPRuntime.isWindows()) {
     219        if (JNLPRuntime.OS_DOS_LIKE) {
    220220            // remove all permissions
    221221            if (!tempFile.setExecutable(false, false)) {
     
    243243                OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RGetXPermFailed", tempFile));
    244244            }
     245
     246            // On OS/2 and Windows, renameTo() fails if the target exists
     247            // so delete it first
     248            file.delete();
     249
    245250            // rename this file. Unless the file is moved/renamed, any program that
    246251            // opened the file right after it was created might still be able to
     
    250255            }
    251256        } else {
    252         // remove all permissions
    253         if (!Defaults.OS_DOS_LIKE) {
     257            // remove all permissions
    254258            if (!tempFile.setExecutable(false, false)) {
    255259                throw new IOException(R("RRemoveXPermFailed", tempFile));
     
    258262                throw new IOException(R("RRemoveRPermFailed", tempFile));
    259263            }
    260         }
    261         if (!tempFile.setWritable(false, false)) {
    262             throw new IOException(R("RRemoveWPermFailed", tempFile));
    263         }
    264 
    265         // allow owner to read
    266         if (!tempFile.setReadable(true, true)) {
    267             throw new IOException(R("RGetRPermFailed", tempFile));
    268         }
    269 
    270         // allow owner to write
    271         if (writableByOwner && !tempFile.setWritable(true, true)) {
    272             throw new IOException(R("RGetWPermFailed", tempFile));
    273         }
    274 
    275         // allow owner to enter directories
    276         if (isDir && !tempFile.setExecutable(true, true)) {
    277             throw new IOException(R("RGetXPermFailed", tempFile));
    278         }
    279        
    280         // rename this file. Unless the file is moved/renamed, any program that
    281         // opened the file right after it was created might still be able to
    282         // read the data.
    283         if (Defaults.OS_DOS_LIKE) {
    284             // On OS/2 and Windows, renameTo() fails if the target exists
    285             // so delete it first
    286             file.delete();
    287         }
    288         if (!tempFile.renameTo(file)) {
    289             throw new IOException(R("RCantRename", tempFile, file));
    290         }
     264            if (!tempFile.setWritable(false, false)) {
     265                throw new IOException(R("RRemoveWPermFailed", tempFile));
     266            }
     267
     268            // allow owner to read
     269            if (!tempFile.setReadable(true, true)) {
     270                throw new IOException(R("RGetRPermFailed", tempFile));
     271            }
     272
     273            // allow owner to write
     274            if (writableByOwner && !tempFile.setWritable(true, true)) {
     275                throw new IOException(R("RGetWPermFailed", tempFile));
     276            }
     277
     278            // allow owner to enter directories
     279            if (isDir && !tempFile.setExecutable(true, true)) {
     280                throw new IOException(R("RGetXPermFailed", tempFile));
     281            }
     282
     283            // rename this file. Unless the file is moved/renamed, any program that
     284            // opened the file right after it was created might still be able to
     285            // read the data.
     286            if (!tempFile.renameTo(file)) {
     287                throw new IOException(R("RCantRename", tempFile, file));
     288            }
    291289        }
    292290
     
    510508    public static FileLock getFileLock(String path, boolean shared, boolean allowBlock) throws FileNotFoundException {
    511509        // @todo temporary solution, see http://svn.netlabs.org/java/ticket/169
    512         if (Defaults.OS_DOS_LIKE)
     510        if (JNLPRuntime.OS_DOS_LIKE)
    513511            return null;
    514512        RandomAccessFile rafFile = new RandomAccessFile(path, "rw");
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/util/lockingfile/LockedFile.java

    r427 r441  
    114114     */
    115115    public void lock() throws IOException {
    116         if (JNLPRuntime.isWindows()) {
     116        // @todo temporary solution, see http://svn.netlabs.org/java/ticket/169
     117        if (JNLPRuntime.OS_DOS_LIKE) {
    117118            return;
    118119        }
     
    141142     */
    142143    public void unlock() throws IOException {
    143         if (JNLPRuntime.isWindows()) {
     144        // @todo temporary solution, see http://svn.netlabs.org/java/ticket/169
     145        if (JNLPRuntime.OS_DOS_LIKE) {
    144146            return;
    145147        }
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/util/logging/OutputController.java

    r427 r441  
    347347
    348348        private static SingleStreamLogger initSystemLogger() {
    349             if (JNLPRuntime.isWindows()) {
     349            if (JNLPRuntime.OS_WIN) {
    350350                return new WinSystemLog();
    351351            } else {
Note: See TracChangeset for help on using the changeset viewer.