Package com.embabel.agent.tools.file
Interface FileWriteTools
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.support.SelfToolPublisher,com.embabel.agent.core.ToolPublisher,com.embabel.agent.core.ToolSpec,com.embabel.agent.tools.DirectoryBased,com.embabel.agent.tools.file.FileAccessLog,com.embabel.agent.tools.file.FileChangeLog
public interface FileWriteTools implements DirectoryBased, FileAccessLog, FileChangeLog, SelfToolPublisher
All file modifications must go through this interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classFileWriteTools.Companion
-
Method Summary
Modifier and Type Method Description List<String>getPathsAccessed()StringcreateFile(String path, String content)Create a file at the relative path under the root PathcreateFile(String path, String content, Boolean overwrite)Create a file with the given content. StringeditFile(String path, String oldContent, String newContent)StringcreateDirectory(String path)StringappendFile(String path, String content)UnitappendToFile(String path, String content, Boolean createIfNotExists)Append content to a file, creating it if it doesn't exist. Stringdelete(String path)-
Methods inherited from class com.embabel.agent.tools.file.FileChangeLog
flushChanges, getChanges, recordChange -
Methods inherited from class com.embabel.agent.tools.DirectoryBased
getRoot -
Methods inherited from class com.embabel.agent.api.common.support.SelfToolPublisher
getTools -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getPathsAccessed
List<String> getPathsAccessed()
-
createFile
String createFile(String path, String content)
Create a file at the relative path under the root
-
createFile
Path createFile(String path, String content, Boolean overwrite)
Create a file with the given content.
- Parameters:
path- the relative path to create the file atcontent- the content to write to the fileoverwrite- if true, overwrite the file if it already exists- Returns:
the path to the created file
-
createDirectory
String createDirectory(String path)
-
appendFile
String appendFile(String path, String content)
-
appendToFile
Unit appendToFile(String path, String content, Boolean createIfNotExists)
Append content to a file, creating it if it doesn't exist. If create is true, the file will be created if it doesn't exist. If createIfNotExists is false, an exception will be thrown if the file doesn't exist.
-
-
-
-