diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-06 16:16:03 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-06 16:16:03 +0900 |
| commit | e68db7fbfc367f25ccbaf57ec43f0f4b3c93cba7 (patch) | |
| tree | cf6c16503c64bc5ca90d155bd7960809d10f272b /system/tmpfiles.go | |
| parent | ac81cfbedc438593f3b504d53728914ac6a3d359 (diff) | |
system: unexport Op implementations
None of these are valid with their zero value, and the implementations assume they are created by the builder methods. They are by all means an implementation detail and exporting them makes no sense.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/tmpfiles.go')
| -rw-r--r-- | system/tmpfiles.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/system/tmpfiles.go b/system/tmpfiles.go index 2850ba22..bd865d44 100644 --- a/system/tmpfiles.go +++ b/system/tmpfiles.go @@ -9,16 +9,16 @@ import ( "syscall" ) -// CopyFile appends [TmpfileOp] to [I]. -func (sys *I) CopyFile(payload *[]byte, src string, cap int, n int64) *I { +// CopyFile reads up to n bytes from src and writes the resulting byte slice to payloadP. +func (sys *I) CopyFile(payloadP *[]byte, src string, cap int, n int64) *I { buf := new(bytes.Buffer) buf.Grow(cap) - sys.ops = append(sys.ops, &TmpfileOp{payload, src, n, buf}) + sys.ops = append(sys.ops, &tmpfileOp{payloadP, src, n, buf}) return sys } -// TmpfileOp reads up to n bytes from src and writes the resulting byte slice to payload. -type TmpfileOp struct { +// tmpfileOp implements [I.CopyFile]. +type tmpfileOp struct { payload *[]byte src string @@ -26,8 +26,9 @@ type TmpfileOp struct { buf *bytes.Buffer } -func (t *TmpfileOp) Type() Enablement { return Process } -func (t *TmpfileOp) apply(*I) error { +func (t *tmpfileOp) Type() Enablement { return Process } + +func (t *tmpfileOp) apply(*I) error { msg.Verbose("copying", t) if t.payload == nil { @@ -55,12 +56,12 @@ func (t *TmpfileOp) apply(*I) error { *t.payload = t.buf.Bytes() return nil } -func (t *TmpfileOp) revert(*I, *Criteria) error { t.buf.Reset(); return nil } +func (t *tmpfileOp) revert(*I, *Criteria) error { t.buf.Reset(); return nil } -func (t *TmpfileOp) Is(o Op) bool { - target, ok := o.(*TmpfileOp) +func (t *tmpfileOp) Is(o Op) bool { + target, ok := o.(*tmpfileOp) return ok && t != nil && target != nil && t.src == target.src && t.n == target.n } -func (t *TmpfileOp) Path() string { return t.src } -func (t *TmpfileOp) String() string { return fmt.Sprintf("up to %d bytes from %q", t.n, t.src) } +func (t *tmpfileOp) Path() string { return t.src } +func (t *tmpfileOp) String() string { return fmt.Sprintf("up to %d bytes from %q", t.n, t.src) } |
