From 7af8484acceeffd4dd8de5f15fc320d7093b53d2 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 23 Aug 2023 19:41:52 +0000 Subject: [PATCH] zones: introduce Machine.OpenFile() Signed-off-by: Alejandro Mery --- pkg/zones/machine_file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/zones/machine_file.go b/pkg/zones/machine_file.go index a9f6eae..8989857 100644 --- a/pkg/zones/machine_file.go +++ b/pkg/zones/machine_file.go @@ -8,6 +8,14 @@ import ( fs "github.com/hack-pad/hackpadfs" ) +// OpenFile opens a file on the machine's config directory with the specified flags +func (m *Machine) OpenFile(name string, flags int, args ...any) (fs.File, error) { + base := m.zone.zones.dir + fullName := m.getFilename(name, args...) + + return fs.OpenFile(base, fullName, flags, 0644) +} + // RemoveFile deletes a file from the machine's config directory func (m *Machine) RemoveFile(name string, args ...any) error { base := m.zone.zones.dir