Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] file:// hack in ProjectRegistryImpl

Hello,

I came across this hack in ProjectRegistryImpl:

 public Project getProject(String projectPath) {
        // HACK
        if (!projectPath.startsWith("file://")) { //$NON-NLS-1$
            projectPath = "file://" + projectPath; //$NON-NLS-1$
        }
        // DONE HACK
final String path = projectPath + File.separatorChar + "project.uprj"; //$NON-NLS-1$


        final URI uri = URI.createURI(path);
        Project project = getProject(uri);
        return project;
    }

I passed a

String projectPath= "F:/workspace/uDig_configuration/myproj.udig";

and it didn't work. Apparently the path needs to be

projectPath= "/F:/workspace/uDig_configuration/myproj.udig";

Then the URL reads

file:///F:/workspace/uDig_configuration/myproj.udig";

and it works. (Notice that no-one in a Windows environment writes a path like "/c:/mydir/myfile.txt".)

So the fix is to add another "/" to
projectPath = "file://" + projectPath; //$NON-NLS-1$

at least for the time being. Also notice that writing a path like

file://///////c:/tmp/my.file

also works! This is crazy, but I've seen so many of those
if (!projectPath.startsWith("file://"))
that I don't get surprised anymore.

Cheers,

Ugo

--
Ugo Taddei

Fraunhofer Institut Intelligente Analyse- und Informationssysteme (FhG IAIS)
http://www.iais.fraunhofer.de
Department Knowledge Discovery - IAIS.KD -
Working Group Spatial Decision Support
http://www.iais.fraunhofer.de/kd.html
phone  (+49)2241-14-2184    fax    (+49)2241-14-2072
Schloss Birlinghoven, D-53754 Sankt Augustin, Germany


Back to the top