Interface FileSystemPort
- All Known Implementing Classes:
LocalFileSystemAdapter
public interface FileSystemPort
Port for file system operations.
This is an output port (drives file system).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classException thrown when file operations fail. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendToFile(Path path, String content) Appends content to an existing file.voidcreateDirectory(Path path) Creates a directory.booleandirectoryExists(Path path) Checks if a directory exists.booleanChecks if a path exists.booleanisProjectEmpty(Path path) Checks if a directory is empty (only contains Gradle files).Lists files in a directory.Reads the content of a file.voidwriteFile(GeneratedFile file) Writes a file to the file system.voidwriteFiles(List<GeneratedFile> files) Writes multiple files to the file system.
-
Method Details
-
writeFile
Writes a file to the file system.- Parameters:
file- the file to write- Throws:
FileSystemPort.FileWriteException- if writing fails
-
writeFiles
Writes multiple files to the file system.- Parameters:
files- the files to write- Throws:
FileSystemPort.FileWriteException- if writing fails
-
createDirectory
Creates a directory.- Parameters:
path- the directory path- Throws:
FileSystemPort.FileWriteException- if creation fails
-
exists
Checks if a path exists.- Parameters:
path- the path to check- Returns:
- true if exists, false otherwise
-
directoryExists
Checks if a directory exists.- Parameters:
path- the directory path- Returns:
- true if exists and is a directory, false otherwise
-
isProjectEmpty
Checks if a directory is empty (only contains Gradle files).- Parameters:
path- the directory path- Returns:
- true if empty or only contains allowed files, false otherwise
-
listFiles
Lists files in a directory.- Parameters:
path- the directory path- Returns:
- list of file paths
-
readFile
Reads the content of a file.- Parameters:
path- the file path- Returns:
- the file content as string
- Throws:
FileSystemPort.FileWriteException- if reading fails
-
appendToFile
Appends content to an existing file.- Parameters:
path- the file pathcontent- the content to append- Throws:
FileSystemPort.FileWriteException- if appending fails
-