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 207060
Collapse All | Expand All

(-)a/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedURLMapper.java (-1 / +9 lines)
Lines 126-132 Link Here
126
        FileObject retVal = null;
126
        FileObject retVal = null;
127
        File file;
127
        File file;
128
        try {
128
        try {
129
            file = FileUtil.normalizeFile(new File(url.toURI()));
129
            file = FileUtil.normalizeFile(uri2File(url.toURI()));
130
        } catch (URISyntaxException e) {
130
        } catch (URISyntaxException e) {
131
            LOG.log(Level.INFO, "URL=" + url, e); // NOI18N
131
            LOG.log(Level.INFO, "URL=" + url, e); // NOI18N
132
            return null;
132
            return null;
Lines 138-143 Link Here
138
        retVal = FileBasedFileSystem.getFileObject(file, FileObjectFactory.Caller.ToFileObject);
138
        retVal = FileBasedFileSystem.getFileObject(file, FileObjectFactory.Caller.ToFileObject);
139
        return new FileObject[]{retVal};
139
        return new FileObject[]{retVal};
140
    }
140
    }
141
    
142
    static File uri2File(URI uri) { // #207060: UNC; candidate for API (#46813)
143
        if (uri.getHost() == null) {
144
            return new File(uri);
145
        } else {
146
            return new File("\\\\" + uri.getHost() + uri.getPath().replace('/', '\\'));
147
        }
148
    }
141
149
142
    private static URL fileToURL(final File file, final FileObject fo) throws MalformedURLException {
150
    private static URL fileToURL(final File file, final FileObject fo) throws MalformedURLException {
143
        URL retVal = toURI(file, fo.isFolder()).toURL();
151
        URL retVal = toURI(file, fo.isFolder()).toURL();
(-)a/masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedURLMapperTest.java (+11 lines)
Lines 50-55 Link Here
50
import org.openide.filesystems.URLMapper;
50
import org.openide.filesystems.URLMapper;
51
import org.openide.filesystems.FileUtil;
51
import org.openide.filesystems.FileUtil;
52
import java.net.URL;
52
import java.net.URL;
53
import org.openide.util.Utilities;
53
54
54
/**
55
/**
55
 * @author Radek Matous
56
 * @author Radek Matous
Lines 91-94 Link Here
91
        assertEquals("192.168.0.201", uri.getHost());
92
        assertEquals("192.168.0.201", uri.getHost());
92
        assertEquals("/data/services/web/com_resource/", uri.getPath());
93
        assertEquals("/data/services/web/com_resource/", uri.getPath());
93
    }
94
    }
95
    
96
    public void testReverseUNCPath() throws Exception {
97
        if (!Utilities.isWindows()) {
98
            return;
99
        }
100
        assertEquals("C:\\some\\random path", FileBasedURLMapper.uri2File(new URI("file:/C:/some/random%20path/")).getAbsolutePath());
101
        assertEquals("C:\\some\\random path", FileBasedURLMapper.uri2File(new URI("file:///C:/some/random%20path/")).getAbsolutePath());
102
        assertEquals("\\\\server\\share\\some\\random path", FileBasedURLMapper.uri2File(new URI("file://server/share/some/random%20path/")).getAbsolutePath());
103
    }
104
    
94
}
105
}
(-)a/o.n.bootstrap/src/org/netbeans/JarClassLoader.java (-1 / +9 lines)
Lines 946-952 Link Here
946
            AGAIN: for (;;) try {
946
            AGAIN: for (;;) try {
947
                final URI uri = new URI(filePath);
947
                final URI uri = new URI(filePath);
948
                if (uri.getScheme().equals("file")) {
948
                if (uri.getScheme().equals("file")) {
949
                    jar = new File(uri).getPath();
949
                    jar = uri2File(uri).getPath();
950
                } else {
950
                } else {
951
                    jar = null;
951
                    jar = null;
952
                }
952
                }
Lines 981-986 Link Here
981
            return new NbJarURLConnection (u, _src, _name, loader);
981
            return new NbJarURLConnection (u, _src, _name, loader);
982
        }
982
        }
983
983
984
        private static File uri2File(URI uri) { // #207060: UNC; candidate for API (#46813)
985
            if (uri.getHost() == null) {
986
                return new File(uri);
987
            } else {
988
                return new File("\\\\" + uri.getHost() + uri.getPath().replace('/', '\\'));
989
            }
990
        }
991
984
        @Override
992
        @Override
985
        protected void parseURL(URL u, String spec, int start, int limit) {
993
        protected void parseURL(URL u, String spec, int start, int limit) {
986
            if (spec.startsWith("/")) {
994
            if (spec.startsWith("/")) {

Return to bug 207060