This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 214438
Collapse All | Expand All

(-)a/core.startup/src/org/netbeans/core/startup/layers/BinaryFS.java (-3 / +30 lines)
Lines 87-92 Link Here
87
import org.openide.util.Lookup;
87
import org.openide.util.Lookup;
88
import org.openide.util.NbBundle;
88
import org.openide.util.NbBundle;
89
import org.openide.util.SharedClassObject;
89
import org.openide.util.SharedClassObject;
90
import org.openide.util.Utilities;
90
import org.openide.util.actions.SystemAction;
91
import org.openide.util.actions.SystemAction;
91
import org.openide.util.io.NbObjectInputStream;
92
import org.openide.util.io.NbObjectInputStream;
92
93
Lines 265-274 Link Here
265
    }
266
    }
266
    private static String toAbsoluteURL(String relURL) {
267
    private static String toAbsoluteURL(String relURL) {
267
        if (relURL.startsWith("home@")) {
268
        if (relURL.startsWith("home@")) {
268
            return "jar:file:" + System.getProperty("netbeans.home") + relURL.substring(5);
269
            return toJarURI(System.getProperty("netbeans.home")) + relURL.substring(5);
269
        }
270
        }
270
        if (relURL.startsWith("user@")) {
271
        if (relURL.startsWith("user@")) {
271
            return "jar:file:" + System.getProperty("netbeans.user") + relURL.substring(5);
272
            return toJarURI(System.getProperty("netbeans.user")) + relURL.substring(5);
272
        }
273
        }
273
        if (relURL.startsWith("abs@")) {
274
        if (relURL.startsWith("abs@")) {
274
            return "jar:file:" + relURL.substring(4);
275
            return "jar:file:" + relURL.substring(4);
Lines 278-284 Link Here
278
            return relURL;
279
            return relURL;
279
        }
280
        }
280
        int cluster = Integer.parseInt(relURL.substring(0, indx));
281
        int cluster = Integer.parseInt(relURL.substring(0, indx));
281
        return "jar:file:" + RelPaths.cluster(cluster) + relURL.substring(indx + 1);
282
        return toJarURI(RelPaths.cluster(cluster)) + relURL.substring(indx + 1);
283
    }
284
285
    private static String toJarURI(String path) {
286
        class DirFile extends File {
287
            public DirFile(String pathname) {
288
                super(pathname);
289
            }
290
291
            @Override
292
            public boolean isDirectory() {
293
                return true;
294
            }
295
296
            @Override
297
            public boolean isFile() {
298
                return false;
299
            }
300
301
            @Override
302
            public File getAbsoluteFile() {
303
                return this;
304
            }
305
        }
306
        String ret = "jar:" + Utilities.toURI(new DirFile(path)).toString(); // NOI18N
307
        assert !ret.contains("//") : ret;
308
        return ret;
282
    }
309
    }
283
    
310
    
284
    @Override
311
    @Override
(-)a/core.startup/src/org/netbeans/core/startup/preferences/RelPaths.java (-13 / +22 lines)
Lines 72-92 Link Here
72
            return null;
72
            return null;
73
        }
73
        }
74
        String[] ret = {null, null};
74
        String[] ret = {null, null};
75
        if (testWritePath(path, System.getProperty("netbeans.user"), "user", ret)) {
75
        testWritePath(path, System.getProperty("netbeans.user"), "user", ret); // NOI18N
76
            return ret;
77
        }
78
        int cnt = 0;
76
        int cnt = 0;
79
        for (String p : dirs()) {
77
        for (String p : dirs()) {
80
            if (testWritePath(path, p, "" + cnt, ret)) {
78
            testWritePath(path, p, "" + cnt, ret);
81
                return ret;
82
            }
83
            cnt++;
79
            cnt++;
84
        }
80
        }
85
        if (testWritePath(path, System.getProperty("netbeans.home"), "home", ret)) {
81
        testWritePath(path, System.getProperty("netbeans.home"), "home", ret); // NOI18N
86
            return ret;
82
        if (ret[1] == null) {
83
            ret[0] = "abs"; // NOI18N
84
            ret[1] = path;
87
        }
85
        }
88
        ret[0] = "abs";
89
        ret[1] = path;
90
        return ret;
86
        return ret;
91
    }
87
    }
92
    
88
    
Lines 144-151 Link Here
144
            return false;
140
            return false;
145
        }
141
        }
146
        if (path.startsWith(prefix)) {
142
        if (path.startsWith(prefix)) {
147
            ret[0] = codeName;
143
            String relPath = path.substring(prefix.length());
148
            ret[1] = path.substring(prefix.length());
144
            while (relPath.startsWith("/")) {
145
                relPath = relPath.substring(1);
146
            }
147
            if (
148
                ret[1] == null || 
149
                ret[1].length() > relPath.length()
150
            ) {
151
                ret[0] = codeName;
152
                ret[1] = relPath;
153
            }
149
            return true;
154
            return true;
150
        }
155
        }
151
        return false;
156
        return false;
Lines 154-160 Link Here
154
    private static synchronized String[] dirs() {
159
    private static synchronized String[] dirs() {
155
        if (dirs == null) {
160
        if (dirs == null) {
156
            List<String> tmp = new ArrayList<String>();
161
            List<String> tmp = new ArrayList<String>();
157
            String nbdirs = System.getProperty("netbeans.dirs");
162
            String nbdirs = System.getProperty("netbeans.dirs"); // NOI18N
158
            if (nbdirs != null) {
163
            if (nbdirs != null) {
159
                StringTokenizer tok = new StringTokenizer(nbdirs, File.pathSeparator);
164
                StringTokenizer tok = new StringTokenizer(nbdirs, File.pathSeparator);
160
                while (tok.hasMoreTokens()) {
165
                while (tok.hasMoreTokens()) {
Lines 165-168 Link Here
165
        }
170
        }
166
        return dirs;
171
        return dirs;
167
    }
172
    }
173
    
174
    static synchronized void assignDirs(String... arr) {
175
        dirs = arr;
176
    }
168
}
177
}
(-)8a9abb71988c (+58 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.core.startup.preferences;
43
44
import org.netbeans.junit.NbTestCase;
45
46
public class RelPathsTest extends NbTestCase {
47
    
48
    public RelPathsTest(String s) {
49
        super(s);
50
    }
51
    
52
    public void testFindRelativePath() {
53
        RelPaths.assignDirs("/root/java", "/root/javacard");
54
        String[] arr = RelPaths.findRelativePath("/root/javacard/isMyFriend");
55
        assertEquals("1", arr[0]);
56
        assertEquals("isMyFriend", arr[1]);
57
    }
58
}

Return to bug 214438