aboutsummaryrefslogtreecommitdiff
path: root/format/packfile/ingest/file_section_writer.go
diff options
context:
space:
mode:
Diffstat (limited to 'format/packfile/ingest/file_section_writer.go')
-rw-r--r--format/packfile/ingest/file_section_writer.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/format/packfile/ingest/file_section_writer.go b/format/packfile/ingest/file_section_writer.go
new file mode 100644
index 00000000..fa28c1a9
--- /dev/null
+++ b/format/packfile/ingest/file_section_writer.go
@@ -0,0 +1,22 @@
+package ingest
+
+import "os"
+
+// fileSectionWriter writes sequentially to file via WriteAt at one base offset.
+type fileSectionWriter struct {
+ file *os.File
+ off int64
+ pos int64
+}
+
+// Write writes src at current section position.
+func (writer *fileSectionWriter) Write(src []byte) (int, error) {
+ if len(src) == 0 {
+ return 0, nil
+ }
+
+ n, err := writer.file.WriteAt(src, writer.off+writer.pos)
+ writer.pos += int64(n)
+
+ return n, err
+}