(String defaultSubDirectory, Box box, Map<Box, String> specialBoxes)
| 559 | protected External toExternal(String defaultSubDirectory, Box box, Map<Box, String> specialBoxes) { |
| 560 | if (specialBoxes.containsKey(box)) return null; |
| 561 | |
| 562 | if (box.properties.isTrue(Boxes.dontSave, false)) return null; |
| 563 | |
| 564 | External ex = new External(); |
| 565 | |
| 566 | ex.id = box.properties.computeIfAbsent(id, (k) -> UUID.randomUUID() |
| 567 | .toString()); |
| 568 | ex.box = box; |
| 569 | |
| 570 | ex.dataFile = relativize(box.properties.computeIfAbsent(new Dict.Prop<String>("__datafilename__"), (k) -> relativize(makeDataFilenameFor(defaultSubDirectory, ex, box)))); |
| 571 | ex.dataFile = ex.dataFile.replace("\\", "/"); |
| 572 | ex.dataFile = ex.dataFile.replace("\\\\", "/"); |
| 573 | ex.dataFile = ex.dataFile.replace("\\\\", "/"); |
| 574 | box.properties.put(new Dict.Prop<String>("__datafilename__"), ex.dataFile); |
| 575 | |
| 576 | System.out.println(" set !datafilename to be :" + ex.dataFile); |
| 577 | |
| 578 | knownProperties.add("__datafilename__"); |
| 579 | |
| 580 | for (Map.Entry<Dict.Prop, Object> e : new LinkedHashMap<>(box.properties.getMap()).entrySet()) { |
| 581 | Log.log("io.general", () -> "checking :" + e.getKey() |
| 582 | .getName() + " against " + knownFiles.keySet()); |
| 583 | if (knownFiles.containsKey(e.getKey() |
| 584 | .getName())) { |
| 585 | Filespec f = knownFiles.get(e.getKey() |
| 586 | .getName()); |
| 587 | |
| 588 | String extantFilename = box.properties.get(new Dict.Prop<String>("__filename__" + e.getKey() |
| 589 | .getName())); |
| 590 | |
| 591 | String fextent = extantFilename; |
| 592 | Log.log("io.general", () -> "extant filename is :" + fextent + " for " + e.getKey() |
| 593 | .getName() + " from " + box.properties); |
| 594 | |
| 595 | // this is wrong. Don't set a name if we are just going to use a default; otherwise, when you move the file you have to update it. |
| 596 | // key it on the datafilename |
| 597 | |
| 598 | if (extantFilename == null) { |
| 599 | extantFilename = relativize(ex.dataFile + f.getDefaultSuffix(box)); |
| 600 | box.properties.put(new Dict.Prop<String>("__filename__" + e.getKey() |
| 601 | .getName()), relativize(extantFilename)); |
| 602 | ex.textFiles.put(e.getKey() |
| 603 | .getName(), relativize(extantFilename)); |
| 604 | } else { |
| 605 | ex.textFiles.put(e.getKey() |
| 606 | .getName(), relativize(extantFilename)); |
| 607 | } |
| 608 | knownProperties.add("__filename__" + e.getKey() |
| 609 | .getName()); |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | |
| 614 | ex.parents = new ArrayList<>(); |
| 615 | ex.children = new ArrayList<>(); |
| 616 | |
| 617 | Set<Box> p = box.parents(); |
| 618 | for (Box pp : p) { |
no test coverage detected