diff --git a/src/org/openstreetmap/josm/io/session/GenericSessionExporter.java b/src/org/openstreetmap/josm/io/session/GenericSessionExporter.java
index 6d1e3eb0d..ab8592c7e 100644
|
a
|
b
|
|
| 12 | 12 | import java.io.File; |
| 13 | 13 | import java.io.IOException; |
| 14 | 14 | import java.io.OutputStream; |
| 15 | | import java.net.MalformedURLException; |
| | 15 | import java.nio.file.Path; |
| 16 | 16 | |
| 17 | 17 | import javax.swing.AbstractAction; |
| 18 | 18 | import javax.swing.ButtonGroup; |
| … |
… |
public Element export(ExportSupport support) throws IOException {
|
| 191 | 191 | file.appendChild(support.createTextNode(zipPath)); |
| 192 | 192 | addDataFile(support.getOutputStreamZip(zipPath)); |
| 193 | 193 | } else { |
| 194 | | try { |
| 195 | | File f = layer.getAssociatedFile(); |
| 196 | | if (f != null) { |
| 197 | | file.appendChild(support.createTextNode(f.toURI().toURL().toString())); |
| | 194 | File f = layer.getAssociatedFile(); |
| | 195 | 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(); |
| 198 | 202 | } |
| 199 | | } catch (MalformedURLException e) { |
| 200 | | throw new IOException(e); |
| | 203 | file.appendChild(support.createTextNode(fileString)); |
| 201 | 204 | } |
| 202 | 205 | } |
| 203 | 206 | return layerEl; |
diff --git a/src/org/openstreetmap/josm/io/session/SessionWriter.java b/src/org/openstreetmap/josm/io/session/SessionWriter.java
index c116c219e..efccebab3 100644
|
a
|
b
|
|
| 8 | 8 | import java.io.OutputStreamWriter; |
| 9 | 9 | import java.nio.charset.StandardCharsets; |
| 10 | 10 | import java.nio.file.Files; |
| | 11 | import java.nio.file.Path; |
| 11 | 12 | import java.util.ArrayList; |
| 12 | 13 | import java.util.Collection; |
| 13 | 14 | import java.util.HashMap; |
| … |
… |
|
| 63 | 64 | private final MultiMap<Layer, Layer> dependencies; |
| 64 | 65 | private final boolean zip; |
| 65 | 66 | |
| | 67 | private Path output; |
| 66 | 68 | private ZipOutputStream zipOut; |
| 67 | 69 | |
| 68 | 70 | static { |
| … |
… |
public OutputStream getOutputStreamZip(String zipPath) throws IOException {
|
| 195 | 197 | public boolean isZip() { |
| 196 | 198 | return zip; |
| 197 | 199 | } |
| | 200 | |
| | 201 | /** |
| | 202 | * Returns the path of the output file. |
| | 203 | * |
| | 204 | * @return the path of the output file |
| | 205 | */ |
| | 206 | public Path getOutput() { |
| | 207 | return output; |
| | 208 | } |
| 198 | 209 | } |
| 199 | 210 | |
| 200 | 211 | /** |
| … |
… |
public void writeJos(Document doc, OutputStream out) throws IOException {
|
| 328 | 339 | * @throws IOException if any I/O error occurs |
| 329 | 340 | */ |
| 330 | 341 | public void write(File f) throws IOException { |
| 331 | | try (OutputStream out = Files.newOutputStream(f.toPath())) { |
| | 342 | output = f.toPath(); |
| | 343 | try (OutputStream out = Files.newOutputStream(output)) { |
| 332 | 344 | write(out); |
| 333 | 345 | } |
| 334 | 346 | } |