Class BFSLinkedFiles

java.lang.Object
megameklab.ui.battlefieldSupport.BFSLinkedFiles

public final class BFSLinkedFiles extends Object
File-side helpers for a linked Battlefield Support Asset: writing the .bfs sidecar next to its base unit's saved file, and offering to delete a stale sidecar when the asset has been disabled. The .bfs location is derived from the base file so linked saving stays convenient (only the base file location is ever prompted).
  • Field Details

  • Method Details

    • handleSidecarOnSave

      public static boolean handleSidecarOnSave(JFrame owner, BFSAssetSource source, File baseFile, @Nullable String baseUnitFileUUID, boolean baseMovedOrNew, @Nullable PopupMessages.UnitFileUUIDChoice baseConflictChoice) throws IOException
      Handles the linked asset's .bfs sidecar when the base unit is saved to baseFile. When the asset is enabled it is re-linked to the base unit's final UUID and written to its resolved target; when disabled, a stale sidecar (if any) is offered for deletion.
      Parameters:
      owner - the owner frame for any dialogs
      source - the editor's asset source (carrier + enable flag + current asset file path)
      baseFile - the base unit file that was just saved
      baseUnitFileUUID - the base unit's final unit-file UUID (the asset's linkedUnitId is set to this so the sidecar links to the base file it is saved alongside, even if the base adopted a different UUID during the save)
      baseMovedOrNew - true when the base was saved to a new/different file (Save As, rename, or first save) — the sidecar is then written fresh next to the new base file rather than to the asset's previous location
      baseConflictChoice - the UUID conflict choice made for the base unit (so the asset's own UUID follows the same decision on a conflict), or null if the base save had no conflict
      Throws:
      IOException - if an enabled linked Asset cannot be written
    • resolveSaveTarget

      public static File resolveSaveTarget(File baseFile, String existingAssetPath, boolean baseMovedOrNew)
      Resolves where the linked asset's .bfs should be written for a base file saved to baseFile.
      • An in-place save (base file unchanged) of an asset that already has a file writes back to that file (wherever it was loaded from), even if its name differs from the base stem.
      • A Save As / rename / first save, or a newly-added asset with no file yet, writes a fresh <baseStem>.bfs next to the base file (self-contained co-located copy).
      Parameters:
      baseFile - the just-saved base unit file
      existingAssetPath - the asset's current file path, or null if it has none
      baseMovedOrNew - whether the base file location changed (or is a first save)
      Returns:
      the .bfs file to write
    • coLocatedSidecar

      public static File coLocatedSidecar(File baseFile)
      Returns:
      the <baseStem>.bfs file in the base file's directory.
    • isInsideZip

      public static boolean isInsideZip(String path)
      Returns:
      whether the given path points inside a zip archive (a cached asset can't be deleted from one).
    • stripExtension

      public static String stripExtension(String fileName)
      Returns:
      the file name without its extension (the part after the last dot).