summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/wiggin77/cfg/srcfile.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-08-05 20:43:19 +0200
committerGitHub <noreply@github.com>2023-08-05 20:43:19 +0200
commit56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch)
treeb1355645342667209263cbd355dc0b4254f1e8fe /vendor/github.com/wiggin77/cfg/srcfile.go
parent9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff)
downloadmatterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.gz
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.bz2
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.zip
Update dependencies and remove old matterclient lib (#2067)HEADmaster
Diffstat (limited to 'vendor/github.com/wiggin77/cfg/srcfile.go')
-rw-r--r--vendor/github.com/wiggin77/cfg/srcfile.go63
1 files changed, 0 insertions, 63 deletions
diff --git a/vendor/github.com/wiggin77/cfg/srcfile.go b/vendor/github.com/wiggin77/cfg/srcfile.go
deleted file mode 100644
index f42c69fa..00000000
--- a/vendor/github.com/wiggin77/cfg/srcfile.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package cfg
-
-import (
- "os"
- "time"
-
- "github.com/wiggin77/cfg/ini"
-)
-
-// SrcFile is a configuration `Source` backed by a file containing
-// name/value pairs or INI format.
-type SrcFile struct {
- AbstractSourceMonitor
- ini ini.Ini
- file *os.File
-}
-
-// NewSrcFileFromFilespec creates a new SrcFile with the specified filespec.
-func NewSrcFileFromFilespec(filespec string) (*SrcFile, error) {
- file, err := os.Open(filespec)
- if err != nil {
- return nil, err
- }
- return NewSrcFile(file)
-}
-
-// NewSrcFile creates a new SrcFile with the specified os.File.
-func NewSrcFile(file *os.File) (*SrcFile, error) {
- sf := &SrcFile{}
- sf.freq = time.Minute
- sf.file = file
- if err := sf.ini.LoadFromFile(file); err != nil {
- return nil, err
- }
- return sf, nil
-}
-
-// GetProps fetches all the properties from a source and returns
-// them as a map.
-func (sf *SrcFile) GetProps() (map[string]string, error) {
- lm, err := sf.GetLastModified()
- if err != nil {
- return nil, err
- }
-
- // Check if we need to reload.
- if sf.ini.GetLastModified() != lm {
- if err := sf.ini.LoadFromFile(sf.file); err != nil {
- return nil, err
- }
- }
- return sf.ini.ToMap(), nil
-}
-
-// GetLastModified returns the time of the latest modification to any
-// property value within the source.
-func (sf *SrcFile) GetLastModified() (time.Time, error) {
- fi, err := sf.file.Stat()
- if err != nil {
- return time.Now(), err
- }
- return fi.ModTime(), nil
-}