From 52ea42be9e3bca722ea8370b88c626ed54e1b02f Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 23 Aug 2023 19:54:55 +0000 Subject: [PATCH] zones: Machine.Create() and Machine.CreateTrunc() Signed-off-by: Alejandro Mery --- pkg/zones/machine_file.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/zones/machine_file.go b/pkg/zones/machine_file.go index 8989857..479bd5b 100644 --- a/pkg/zones/machine_file.go +++ b/pkg/zones/machine_file.go @@ -16,6 +16,16 @@ func (m *Machine) OpenFile(name string, flags int, args ...any) (fs.File, error) return fs.OpenFile(base, fullName, flags, 0644) } +// CreateTrunc creates or truncates a file on the machine's config directory +func (m *Machine) CreateTrunc(name string, args ...any) (fs.File, error) { + return m.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, args...) +} + +// Create creates a file on the machine's config directory +func (m *Machine) Create(name string, args ...any) (fs.File, error) { + return m.OpenFile(name, os.O_RDWR|os.O_CREATE, args...) +} + // RemoveFile deletes a file from the machine's config directory func (m *Machine) RemoveFile(name string, args ...any) error { base := m.zone.zones.dir