zones: Machine.CreateFile() and Machine.CreateTruncFile()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-23 19:54:55 +00:00
parent 903e677071
commit 256c58cddc
+10
View File
@@ -16,6 +16,16 @@ func (m *Machine) OpenFile(name string, flags int, args ...any) (fs.File, error)
return fs.OpenFile(base, fullName, flags, 0644)
}
// CreateTruncFile creates or truncates a file on the machine's config directory
func (m *Machine) CreateTruncFile(name string, args ...any) (fs.File, error) {
return m.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, args...)
}
// CreateFile creates a file on the machine's config directory
func (m *Machine) CreateFile(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