Changeset 6151 in josm


Ignore:
Timestamp:
2013-08-16T10:13:47+02:00 (8 years ago)
Author:
bastiK
Message:

#8972 - Receiving nullpointer exception when loading map style whose paths are relative to zip root

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEntry.java

    r6148 r6151  
    159159    /**
    160160     * Returns the parent directory of the resource inside the zip file.
    161      * @return null, if zipEntryPath is null, otherwise the parent directory of
    162      * the resource inside the zip file
     161     * @return the parent directory of the resource inside the zip file,
     162     * "." if zipEntryPath is a top level file; null, if zipEntryPath is null
    163163     */
    164164    public String getZipEntryDirName() {
    165165        if (zipEntryPath == null) return null;
    166         return new File(zipEntryPath).getParent().toString();
     166        File file = new File(zipEntryPath);
     167        File dir = file.getParentFile();
     168        if (dir == null) return ".";
     169        return dir.getPath();
    167170    }
    168171}
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r6148 r6151  
    539539        {
    540540            zipFile = new ZipFile(archive);
    541             String entry_name;
    542             if (inArchiveDir != null) {
    543                 File dir = new File(inArchiveDir);
    544                 entry_name = new File(dir, full_name).getPath();
    545             } else {
    546                 entry_name = full_name;
    547             }
     541            if (inArchiveDir == null || inArchiveDir.equals(".")) {
     542                inArchiveDir = "";
     543            } else if (!inArchiveDir.isEmpty()) {
     544                inArchiveDir += "/";
     545            }
     546            String entry_name = inArchiveDir + full_name;
    548547            ZipEntry entry = zipFile.getEntry(entry_name);
    549548            if(entry != null)
Note: See TracChangeset for help on using the changeset viewer.