Skip to content

Commit 5b02de0

Browse files
avrabeclaude
andcommitted
fix: implement concatenate_files operation in file_ops
Add support for concatenate_files operation which is used by the Rust wit-bindgen wrapper to combine multiple generated binding files into a single output file. This operation: 1. Accepts a list of source file paths to concatenate 2. Opens the destination file for writing 3. Reads and writes each source file sequentially 4. Handles errors gracefully with proper logging This fixes the "Unknown operation type: concatenate_files" error that was blocking CI on the Phase 4 feature branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 61e01a5 commit 5b02de0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tools/file_ops/main.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,47 @@ func main() {
152152
})
153153
log.Printf("DEBUG: Copied directory contents from %s to %s", srcDir, destDir)
154154

155+
case "concatenate_files":
156+
// Concatenate multiple files into one
157+
srcPaths, ok := opMap["src_paths"].([]interface{})
158+
if !ok {
159+
log.Printf("ERROR: concatenate_files operation missing src_paths")
160+
os.Exit(1)
161+
}
162+
163+
destPath := filepath.Join(workspaceFullPath, opMap["dest_path"].(string))
164+
os.MkdirAll(filepath.Dir(destPath), 0755)
165+
166+
// Open destination file for writing
167+
destFile, err := os.Create(destPath)
168+
if err != nil {
169+
log.Printf("ERROR: Failed to create destination file %s: %v", destPath, err)
170+
os.Exit(1)
171+
}
172+
defer destFile.Close()
173+
174+
// Concatenate each source file
175+
for _, srcPath := range srcPaths {
176+
srcPathStr, ok := srcPath.(string)
177+
if !ok {
178+
log.Printf("ERROR: Invalid source path in concatenate_files")
179+
os.Exit(1)
180+
}
181+
182+
data, err := ioutil.ReadFile(srcPathStr)
183+
if err != nil {
184+
log.Printf("ERROR: Failed to read source file %s: %v", srcPathStr, err)
185+
os.Exit(1)
186+
}
187+
188+
if _, err := destFile.Write(data); err != nil {
189+
log.Printf("ERROR: Failed to write to destination file %s: %v", destPath, err)
190+
os.Exit(1)
191+
}
192+
}
193+
194+
log.Printf("DEBUG: Concatenated %d files to %s", len(srcPaths), destPath)
195+
155196
default:
156197
log.Printf("WARNING: Unknown operation type: %s", opType)
157198
}

0 commit comments

Comments
 (0)