diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-17 17:54:28 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-17 18:17:55 +0900 |
| commit | b1e1d5627e6532ec719c761846d7f38fe93fcadd (patch) | |
| tree | 2a308de9ee6a53b536ad00877158dc959e9cdea4 /internal/system/mkdir.go | |
| parent | 3ae2ab652e9cd1d6250dbde8ae0f9b9fe90afc72 (diff) | |
system: wrap console output functions
This eliminates all fmsg imports from internal/system.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system/mkdir.go')
| -rw-r--r-- | internal/system/mkdir.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/internal/system/mkdir.go b/internal/system/mkdir.go index 855b339d..524289e5 100644 --- a/internal/system/mkdir.go +++ b/internal/system/mkdir.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" "os" - - "git.gensokyo.uk/security/fortify/internal/fmsg" ) // Ensure the existence and mode of a directory. @@ -39,33 +37,33 @@ func (m *Mkdir) Type() Enablement { return m.et } -func (m *Mkdir) apply(_ *I) error { - fmsg.Verbose("ensuring directory", m) +func (m *Mkdir) apply(sys *I) error { + sys.println("ensuring directory", m) // create directory err := os.Mkdir(m.path, m.perm) if !errors.Is(err, os.ErrExist) { - return fmsg.WrapErrorSuffix(err, + return sys.wrapErrSuffix(err, fmt.Sprintf("cannot create directory %q:", m.path)) } // directory exists, ensure mode - return fmsg.WrapErrorSuffix(os.Chmod(m.path, m.perm), + return sys.wrapErrSuffix(os.Chmod(m.path, m.perm), fmt.Sprintf("cannot change mode of %q to %s:", m.path, m.perm)) } -func (m *Mkdir) revert(_ *I, ec *Criteria) error { +func (m *Mkdir) revert(sys *I, ec *Criteria) error { if !m.ephemeral { // skip non-ephemeral dir and do not log anything return nil } if ec.hasType(m) { - fmsg.Verbose("destroying ephemeral directory", m) - return fmsg.WrapErrorSuffix(os.Remove(m.path), + sys.println("destroying ephemeral directory", m) + return sys.wrapErrSuffix(os.Remove(m.path), fmt.Sprintf("cannot remove ephemeral directory %q:", m.path)) } else { - fmsg.Verbose("skipping ephemeral directory", m) + sys.println("skipping ephemeral directory", m) return nil } } |
