Mercurial > go > multipass
diff file/file.go @ 18:00d30c67b56d
Put all the library stuff into multipass/file.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 01 Nov 2015 12:16:51 -0500 |
parents | 9b4ec6b5c23e |
children | ef2ef22ca4b1 |
line wrap: on
line diff
--- a/file/file.go Fri Oct 30 00:18:13 2015 -0400 +++ b/file/file.go Sun Nov 01 12:16:51 2015 -0500 @@ -2,7 +2,7 @@ // // A password file contains multiple passwords for a single user. // It starts with a banner that indicates the version of the file, -// then has entries in the format specified by auth.Entry. +// then has entries in the format specified by Entry. package file @@ -14,7 +14,6 @@ "time" "golang.org/x/sys/unix" - "pfish.zone/go/multipass/auth" ) const ( @@ -73,7 +72,7 @@ defer file.Close() for scanner.Scan() { - entry, err := auth.EntryFromShadow(scanner.Text()) + entry, err := EntryFromShadow(scanner.Text()) // Skip invalid lines. if err != nil { continue @@ -85,7 +84,7 @@ return false, nil } -func (f *ShadowFile) Add(entry *auth.Entry) error { +func (f *ShadowFile) Add(entry *Entry) error { handle, err := f.openWrite() if err != nil { return err @@ -107,17 +106,17 @@ return handle.finalize() } -func (f *ShadowFile) AllEntries() ([]*auth.Entry, error) { +func (f *ShadowFile) AllEntries() ([]*Entry, error) { file, scanner, err := f.open() if err != nil { return nil, err } defer file.Close() - var entries []*auth.Entry + var entries []*Entry for scanner.Scan() { - entry, err := auth.EntryFromShadow(scanner.Text()) + entry, err := EntryFromShadow(scanner.Text()) // Skip invalid lines. if err != nil { continue @@ -242,11 +241,11 @@ return h.scanner != nil && h.scanner.Scan() } -func (h *writeHandle) entry() (*auth.Entry, error) { - return auth.EntryFromShadow(h.scanner.Text()) +func (h *writeHandle) entry() (*Entry, error) { + return EntryFromShadow(h.scanner.Text()) } -func (h *writeHandle) write(entry *auth.Entry) error { +func (h *writeHandle) write(entry *Entry) error { if _, err := h.writer.WriteString(entry.Encode()); err != nil { return err }