Class FilesystemUtils
java.lang.Object
io.agentscope.harness.agent.filesystem.util.FilesystemUtils
Shared utility functions for filesystem implementations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcountOccurrences(String text, String sub) Count non-overlapping occurrences of a substring.static StringgetFileType(String path) Classify a file as "text" or "binary" based on extension.static Object[]performStringReplacement(String content, String oldString, String newString, boolean replaceAll) Perform string replacement with occurrence validation.static StringshellQuote(String s) Shell-escape a string for safe use in shell commands.
-
Method Details
-
getFileType
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
Count non-overlapping occurrences of a substring. -
shellQuote
Shell-escape a string for safe use in shell commands.
-