Class CopyFile

java.lang.Object
io.github.raghultech.openloom.fs.CopyFile

public class CopyFile extends Object
================================================================ 📄 CopyFile - Internal File Copy Utility ================================================================

Overview: Internal utility class used by OpenLoom to copy a single file from a source path to a target path. Supports preserving file attributes and optionally replacing existing files.

Important: This is a protected/internal class. End-users should not use this class directly. To copy files, use the FileManager APIs from OpenLoom:


 OpenLoom loom = new OpenLoom();
 loom.file().copyFile(Paths.get("C:/source.txt"), Paths.get("C:/target.txt"), true);
 

Key features:

  • ✅ Copies files safely and efficiently
  • âš¡ Preserves basic file attributes such as last modified time
  • 🔄 Supports replaceExisting flag to overwrite files
  • 🧠 Automatically resolves target path conflicts
  • Constructor Details

    • CopyFile

      public CopyFile()
  • Method Details

    • copyInternal

      protected void copyInternal(Path source, Path target, boolean replaceExisting)
      Copy a file from source to target.

      This method handles file validation, resolves the final target path, preserves file attributes, and optionally replaces existing files.

      Important behavior:

      • If replaceExisting is true, the target file is overwritten.
      • Throws OpenLoomFileException for validation or I/O errors.

      Note: This method is protected and intended to be used only through OpenLoom's FileManager class.

      Parameters:
      source - the source file to copy
      target - the target file path
      replaceExisting - whether to replace the target file if it exists
      Throws:
      OpenLoomFileException - if an I/O error occurs or file validation fails