Class MoveDirectory

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

public class MoveDirectory extends Object
================================================================ 📂 MoveDirectory - Directory Move Utility ================================================================

Overview: Provides a robust method to move directories from a source path to a target path. Supports optional replacement of existing directories and prevents moving a directory into itself or its subdirectories.

Important: This class is protected and intended for internal usage. End-users should access directory move operations via FileManager:


 OpenLoom loom = new OpenLoom();
 loom.file().moveDir(Paths.get("C:/sourceDir"), Paths.get("C:/targetDir"), true);
 

Key features:

  • ✅ Moves directories safely and efficiently
  • âš¡ Supports optional overwriting of existing directories
  • 🧠 Prevents recursive moves into self or subdirectories
  • 🔄 Wraps I/O errors in detailed OpenLoomFileException
  • Constructor Details

    • MoveDirectory

      public MoveDirectory()
  • Method Details

    • moveInternal

      protected void moveInternal(Path source, Path target, boolean replaceExisting)
      Moves a directory from source to target.

      If replaceExisting is true, an existing target directory will be replaced. Throws an exception if the target is inside the source directory to prevent recursion.

      Parameters:
      source - the source directory to move
      target - the target directory where the source will be moved
      replaceExisting - whether to replace existing target directory
      Throws:
      OpenLoomFileException - if validation fails or an I/O error occurs