File: instance_raw_writer.go

package info (click to toggle)
incus 6.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,220 kB
  • sloc: sh: 16,810; ansic: 3,122; python: 460; makefile: 341; ruby: 51; sql: 50; lisp: 6
file content (30 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package instancewriter

import (
	"io"
	"os"
)

// InstanceRawWriter provides an InstanceWriter implementation that copies the contents of a file to another.
type InstanceRawWriter struct {
	rawWriter io.WriteCloser
}

// NewInstanceRawWriter returns an InstanceRawWriter for the provided target file.
func NewInstanceRawWriter(writer io.WriteCloser) *InstanceRawWriter {
	return &InstanceRawWriter{rawWriter: writer}
}

// ResetHardLinkMap is a no-op.
func (crw *InstanceRawWriter) ResetHardLinkMap() {}

// WriteFile is a no-op.
func (crw *InstanceRawWriter) WriteFile(name string, srcPath string, fi os.FileInfo, ignoreGrowth bool) error {
	return nil
}

// WriteFileFromReader streams a file into the target file.
func (crw *InstanceRawWriter) WriteFileFromReader(src io.Reader, fi os.FileInfo) error {
	_, err := io.CopyN(crw.rawWriter, src, fi.Size())
	return err
}