Compare commits
2 Commits
52ea42be9e
...
15f28fa7c8
| Author | SHA1 | Date | |
|---|---|---|---|
| 15f28fa7c8 | |||
| 6838d00a0a |
@@ -8,6 +8,24 @@ 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)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user