Class DirectoryCopy

java.lang.Object
org.ek9lang.core.DirectoryCopy
All Implemented Interfaces:
BiFunction<File, File, DirectoryCopy.CopyOutcome>

public final class DirectoryCopy extends Object implements BiFunction<File, File, DirectoryCopy.CopyOutcome>
THE copy of a dependency's verified unpack into a project (D-M2, P2; docs/implementation/EK9_P2_P3_PLAN.md ยง1.3): stages a full copy of source under a sibling .staging-<destinationName>-<nanoTime> folder, hashing every regular file (SHA-256, lower-case hex) as it goes, then deletes any previous destination and renames the staging folder into place over it. This is NOT atomic on any platform - between the delete and the rename there is a window in which destination does not exist at all (never a half-copy: the staging folder holds the full new content until the rename, and a reader in that window simply finds destination briefly missing). A crash in that window, or anywhere earlier, leaves only a .staging-* folder; one left behind more than STALE_STAGING_AGE ago is removed before the NEXT copy under the same parent folder starts its own - never a FRESH .staging-* folder, which is another process's copy still in flight. Refuses a symbolic link anywhere in the tree (a library folder is plain files; Packager.unpack(File, File) refuses the same for an escaping zip entry) - nothing is left of a refused copy, and destination is left exactly as it was. Hold one.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    The outcome of a copy: it succeeded, with the hash of every file copied; or a symbolic link refused it (refusedEntry names its path, relative to the source); or it failed for another reason (refusedEntry says why).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(File source, File destination)
    Copy source (a readable directory) into place at destination: destination's parent is created if it does not yet exist; destination itself is replaced atomically.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface BiFunction

    andThen
  • Constructor Details

    • DirectoryCopy

      public DirectoryCopy()
  • Method Details

    • apply

      public DirectoryCopy.CopyOutcome apply(File source, File destination)
      Copy source (a readable directory) into place at destination: destination's parent is created if it does not yet exist; destination itself is replaced atomically. A symbolic link anywhere under source refuses the whole copy, leaving destination untouched.
      Specified by:
      apply in interface BiFunction<File, File, DirectoryCopy.CopyOutcome>