- Timestamp:
- 2019-01-21T23:07:32+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/session
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/session/GenericSessionExporter.java
r14630 r14718 13 13 import java.io.IOException; 14 14 import java.io.OutputStream; 15 import java.nio.file.Path;16 15 17 16 import javax.swing.AbstractAction; … … 194 193 File f = layer.getAssociatedFile(); 195 194 if (f != null) { 196 final Path sessionDirectory = support.getOutput().getParent(); 197 final String fileString; 198 if (f.toPath().startsWith(sessionDirectory)) { 199 fileString = sessionDirectory.relativize(f.toPath()).toString(); 200 } else { 201 fileString = f.toPath().toString(); 202 } 195 final String fileString = support.relativize(f.toPath()); 203 196 file.appendChild(support.createTextNode(fileString)); 204 197 } -
trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionExporter.java
r12620 r14718 69 69 break; 70 70 } 71 addAttr("file",entry.getFile().getPath(), imgElem, support);72 // FIXME: relative filenames as option71 final String fileString = support.relativize(entry.getFile().toPath()); 72 addAttr("file", fileString, imgElem, support); 73 73 // FIXME: include images as option (?) 74 74 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r14630 r14718 207 207 return output; 208 208 } 209 210 /** 211 * Returns a relative path w.r.t. the {@linkplain #getOutput output} directory 212 * @param path the path to relativize 213 * @return the relative path 214 * @see Path#relativize(Path) 215 */ 216 String relativize(final Path path) { 217 if (getOutput() == null) { 218 return path.toString(); 219 } 220 final Path sessionDirectory = getOutput().getParent(); 221 if (path.startsWith(sessionDirectory)) { 222 return sessionDirectory.relativize(path).toString(); 223 } else { 224 return path.toString(); 225 } 226 } 209 227 } 210 228
Note:
See TracChangeset
for help on using the changeset viewer.