Class FilesystemUtils

java.lang.Object
io.agentscope.harness.agent.filesystem.util.FilesystemUtils

public final class FilesystemUtils extends Object
Shared utility functions for filesystem implementations.
  • Method Details

    • getFileType

      public static String getFileType(String path)
      Classify a file as "text" or "binary" based on extension.
    • performStringReplacement

      public static Object[] performStringReplacement(String content, String oldString, String newString, boolean replaceAll)
      Perform string replacement with occurrence validation.
      Returns:
      a two-element array [newContent, occurrenceCount] on success, or a single-element array [errorMessage] on failure
    • countOccurrences

      public static int countOccurrences(String text, String sub)
      Count non-overlapping occurrences of a substring.
    • shellQuote

      public static String shellQuote(String s)
      Shell-escape a string for safe use in shell commands.