FilesystemUtils
public final class FilesystemUtils
源码Source
io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:23–107文件系统 Utils,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.filesystem.util 包。核心成员包括 getFileType、performStringReplacement、countOccurrences、shellQuote。
Shared utility functions for filesystem implementations.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static String getFileType(String path)static | 获取文件类型。 Classify a file as "text" or "binary" based on extension. |
public static Object[] performStringReplacement(String content, String oldString, String newString, boolean replaceAll)static | 执行 `performStringReplacement` 方法。 Perform string replacement with occurrence validation. |
public static int countOccurrences(String text, String sub)static | 执行 `countOccurrences` 方法。 Count non-overlapping occurrences of a substring. |
public static String shellQuote(String s)static | 设置该参数。 Shell-escape a string for safe use in shell commands. |
方法详情Method Detail
getFileType
public static String getFileType(String path)
static
获取文件类型。
Classify a file as "text" or "binary" based on extension.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。The path. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:38–48performStringReplacement
public static Object[] performStringReplacement(String content, String oldString, String newString, boolean replaceAll)
static
执行 performStringReplacement 方法。
Perform string replacement with occurrence validation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
content | String | 内容(类型 `String`)。The content. |
oldString | String | 旧的 String(类型 `String`)。The old string. |
newString | String | 新建 String(类型 `String`)。The new string. |
replaceAll | boolean | replace 所有(类型 `boolean`)。The replace all. |
Object[]返回对象[]。a two-element array `[newContent, occurrenceCount]` on success, or a single-element array `[errorMessage]` on failure
源码Source
io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:56–87countOccurrences
public static int countOccurrences(String text, String sub)
static
执行 countOccurrences 方法。
Count non-overlapping occurrences of a substring.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
sub | String | 子(类型 `String`)。The sub. |
int返回数值结果。Returns a numeric result.
源码Source
io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:90–98shellQuote
public static String shellQuote(String s)
static
设置该参数。
Shell-escape a string for safe use in shell commands.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
s | String | s(类型 `String`)。The s. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:101–106