|
|
@ -2,10 +2,26 @@ package zones |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io/fs" |
|
|
|
"os" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs "github.com/hack-pad/hackpadfs" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RemoveFile deletes a file from the machine's config directory
|
|
|
|
|
|
|
|
func (m *Machine) RemoveFile(name string, args ...any) error { |
|
|
|
|
|
|
|
base := m.zone.zones.dir |
|
|
|
|
|
|
|
fullName := m.getFilename(name, args...) |
|
|
|
|
|
|
|
err := fs.Remove(base, fullName) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case os.IsNotExist(err): |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ReadFile reads a file from the machine's config directory
|
|
|
|
// ReadFile reads a file from the machine's config directory
|
|
|
|
func (m *Machine) ReadFile(name string, args ...any) ([]byte, error) { |
|
|
|
func (m *Machine) ReadFile(name string, args ...any) ([]byte, error) { |
|
|
|
base := m.zone.zones.dir |
|
|
|
base := m.zone.zones.dir |
|
|
|