[vendor] remove shibukawa/configdir as I have moved to QSettings
This commit is contained in:
parent
aaa7dcbe2f
commit
8186c6cdba
21
vendor/github.com/shibukawa/configdir/LICENSE
generated
vendored
21
vendor/github.com/shibukawa/configdir/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 shibukawa
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
111
vendor/github.com/shibukawa/configdir/README.rst
generated
vendored
111
vendor/github.com/shibukawa/configdir/README.rst
generated
vendored
@ -1,111 +0,0 @@
|
|||||||
configdir for Golang
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Multi platform library of configuration directory for Golang.
|
|
||||||
|
|
||||||
This library helps to get regular directories for configuration files or cache files that matches target operationg system's convention.
|
|
||||||
|
|
||||||
It assumes the following folders are standard paths of each environment:
|
|
||||||
|
|
||||||
.. list-table::
|
|
||||||
:header-rows: 1
|
|
||||||
|
|
||||||
- *
|
|
||||||
* Windows:
|
|
||||||
* Linux/BSDs:
|
|
||||||
* MacOSX:
|
|
||||||
- * System level configuration folder
|
|
||||||
* ``%PROGRAMDATA%`` (``C:\\ProgramData``)
|
|
||||||
* ``${XDG_CONFIG_DIRS}`` (``/etc/xdg``)
|
|
||||||
* ``/Library/Application Support``
|
|
||||||
- * User level configuration folder
|
|
||||||
* ``%APPDATA%`` (``C:\\Users\\<User>\\AppData\\Roaming``)
|
|
||||||
* ``${XDG_CONFIG_HOME}`` (``${HOME}/.config``)
|
|
||||||
* ``${HOME}/Library/Application Support``
|
|
||||||
- * User wide cache folder
|
|
||||||
* ``%LOCALAPPDATA%`` ``(C:\\Users\\<User>\\AppData\\Local)``
|
|
||||||
* ``${XDG_CACHE_HOME}`` (``${HOME}/.cache``)
|
|
||||||
* ``${HOME}/Library/Caches``
|
|
||||||
|
|
||||||
Examples
|
|
||||||
------------
|
|
||||||
|
|
||||||
Getting Configuration
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
``configdir.ConfigDir.QueryFolderContainsFile()`` searches files in the following order:
|
|
||||||
|
|
||||||
* Local path (if you add the path via LocalPath parameter)
|
|
||||||
* User level configuration folder(e.g. ``$HOME/.config/<vendor-name>/<application-name>/setting.json`` in Linux)
|
|
||||||
* System level configuration folder(e.g. ``/etc/xdg/<vendor-name>/<application-name>/setting.json`` in Linux)
|
|
||||||
|
|
||||||
``configdir.Config`` provides some convenient methods(``ReadFile``, ``WriteFile`` and so on).
|
|
||||||
|
|
||||||
.. code-block:: go
|
|
||||||
|
|
||||||
var config Config
|
|
||||||
|
|
||||||
configDirs := configdir.New("vendor-name", "application-name")
|
|
||||||
// optional: local path has the highest priority
|
|
||||||
configDirs.LocalPath, _ = filepath.Abs(".")
|
|
||||||
folder := configDirs.QueryFolderContainsFile("setting.json")
|
|
||||||
if folder != nil {
|
|
||||||
data, _ := folder.ReadFile("setting.json")
|
|
||||||
json.Unmarshal(data, &config)
|
|
||||||
} else {
|
|
||||||
config = DefaultConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
Write Configuration
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
When storing configuration, get configuration folder by using ``configdir.ConfigDir.QueryFolders()`` method.
|
|
||||||
|
|
||||||
.. code-block:: go
|
|
||||||
|
|
||||||
configDirs := configdir.New("vendor-name", "application-name")
|
|
||||||
|
|
||||||
var config Config
|
|
||||||
data, _ := json.Marshal(&config)
|
|
||||||
|
|
||||||
// Stores to local folder
|
|
||||||
folders := configDirs.QueryFolders(configdir.Local)
|
|
||||||
folders[0].WriteFile("setting.json", data)
|
|
||||||
|
|
||||||
// Stores to user folder
|
|
||||||
folders = configDirs.QueryFolders(configdir.Global)
|
|
||||||
folders[0].WriteFile("setting.json", data)
|
|
||||||
|
|
||||||
// Stores to system folder
|
|
||||||
folders = configDirs.QueryFolders(configdir.System)
|
|
||||||
folders[0].WriteFile("setting.json", data)
|
|
||||||
|
|
||||||
Getting Cache Folder
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
It is similar to the above example, but returns cache folder.
|
|
||||||
|
|
||||||
.. code-block:: go
|
|
||||||
|
|
||||||
configDirs := configdir.New("vendor-name", "application-name")
|
|
||||||
cache := configDirs.QueryCacheFolder()
|
|
||||||
|
|
||||||
resp, err := http.Get("http://examples.com/sdk.zip")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
|
|
||||||
cache.WriteFile("sdk.zip", body)
|
|
||||||
|
|
||||||
Document
|
|
||||||
------------
|
|
||||||
|
|
||||||
https://godoc.org/github.com/shibukawa/configdir
|
|
||||||
|
|
||||||
License
|
|
||||||
------------
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
160
vendor/github.com/shibukawa/configdir/config.go
generated
vendored
160
vendor/github.com/shibukawa/configdir/config.go
generated
vendored
@ -1,160 +0,0 @@
|
|||||||
// configdir provides access to configuration folder in each platforms.
|
|
||||||
//
|
|
||||||
// System wide configuration folders:
|
|
||||||
//
|
|
||||||
// - Windows: %PROGRAMDATA% (C:\ProgramData)
|
|
||||||
// - Linux/BSDs: ${XDG_CONFIG_DIRS} (/etc/xdg)
|
|
||||||
// - MacOSX: "/Library/Application Support"
|
|
||||||
//
|
|
||||||
// User wide configuration folders:
|
|
||||||
//
|
|
||||||
// - Windows: %APPDATA% (C:\Users\<User>\AppData\Roaming)
|
|
||||||
// - Linux/BSDs: ${XDG_CONFIG_HOME} (${HOME}/.config)
|
|
||||||
// - MacOSX: "${HOME}/Library/Application Support"
|
|
||||||
//
|
|
||||||
// User wide cache folders:
|
|
||||||
//
|
|
||||||
// - Windows: %LOCALAPPDATA% (C:\Users\<User>\AppData\Local)
|
|
||||||
// - Linux/BSDs: ${XDG_CACHE_HOME} (${HOME}/.cache)
|
|
||||||
// - MacOSX: "${HOME}/Library/Caches"
|
|
||||||
//
|
|
||||||
// configdir returns paths inside the above folders.
|
|
||||||
|
|
||||||
package configdir
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ConfigType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
System ConfigType = iota
|
|
||||||
Global
|
|
||||||
All
|
|
||||||
Existing
|
|
||||||
Local
|
|
||||||
Cache
|
|
||||||
)
|
|
||||||
|
|
||||||
// Config represents each folder
|
|
||||||
type Config struct {
|
|
||||||
Path string
|
|
||||||
Type ConfigType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) Open(fileName string) (*os.File, error) {
|
|
||||||
return os.Open(filepath.Join(c.Path, fileName))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) Create(fileName string) (*os.File, error) {
|
|
||||||
err := c.CreateParentDir(fileName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return os.Create(filepath.Join(c.Path, fileName))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) ReadFile(fileName string) ([]byte, error) {
|
|
||||||
return ioutil.ReadFile(filepath.Join(c.Path, fileName))
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateParentDir creates the parent directory of fileName inside c. fileName
|
|
||||||
// is a relative path inside c, containing zero or more path separators.
|
|
||||||
func (c Config) CreateParentDir(fileName string) error {
|
|
||||||
return os.MkdirAll(filepath.Dir(filepath.Join(c.Path, fileName)), 0755)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) WriteFile(fileName string, data []byte) error {
|
|
||||||
err := c.CreateParentDir(fileName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return ioutil.WriteFile(filepath.Join(c.Path, fileName), data, 0644)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) MkdirAll() error {
|
|
||||||
return os.MkdirAll(c.Path, 0755)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Config) Exists(fileName string) bool {
|
|
||||||
_, err := os.Stat(filepath.Join(c.Path, fileName))
|
|
||||||
return !os.IsNotExist(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfigDir keeps setting for querying folders.
|
|
||||||
type ConfigDir struct {
|
|
||||||
VendorName string
|
|
||||||
ApplicationName string
|
|
||||||
LocalPath string
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(vendorName, applicationName string) ConfigDir {
|
|
||||||
return ConfigDir{
|
|
||||||
VendorName: vendorName,
|
|
||||||
ApplicationName: applicationName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c ConfigDir) joinPath(root string) string {
|
|
||||||
if c.VendorName != "" && hasVendorName {
|
|
||||||
return filepath.Join(root, c.VendorName, c.ApplicationName)
|
|
||||||
}
|
|
||||||
return filepath.Join(root, c.ApplicationName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c ConfigDir) QueryFolders(configType ConfigType) []*Config {
|
|
||||||
if configType == Cache {
|
|
||||||
return []*Config{c.QueryCacheFolder()}
|
|
||||||
}
|
|
||||||
var result []*Config
|
|
||||||
if c.LocalPath != "" && configType != System && configType != Global {
|
|
||||||
result = append(result, &Config{
|
|
||||||
Path: c.LocalPath,
|
|
||||||
Type: Local,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if configType != System && configType != Local {
|
|
||||||
result = append(result, &Config{
|
|
||||||
Path: c.joinPath(globalSettingFolder),
|
|
||||||
Type: Global,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if configType != Global && configType != Local {
|
|
||||||
for _, root := range systemSettingFolders {
|
|
||||||
result = append(result, &Config{
|
|
||||||
Path: c.joinPath(root),
|
|
||||||
Type: System,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if configType != Existing {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
var existing []*Config
|
|
||||||
for _, entry := range result {
|
|
||||||
if _, err := os.Stat(entry.Path); !os.IsNotExist(err) {
|
|
||||||
existing = append(existing, entry)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return existing
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c ConfigDir) QueryFolderContainsFile(fileName string) *Config {
|
|
||||||
configs := c.QueryFolders(Existing)
|
|
||||||
for _, config := range configs {
|
|
||||||
if _, err := os.Stat(filepath.Join(config.Path, fileName)); !os.IsNotExist(err) {
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c ConfigDir) QueryCacheFolder() *Config {
|
|
||||||
return &Config{
|
|
||||||
Path: c.joinPath(cacheFolder),
|
|
||||||
Type: Cache,
|
|
||||||
}
|
|
||||||
}
|
|
8
vendor/github.com/shibukawa/configdir/config_darwin.go
generated
vendored
8
vendor/github.com/shibukawa/configdir/config_darwin.go
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
package configdir
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
var hasVendorName = true
|
|
||||||
var systemSettingFolders = []string{"/Library/Application Support"}
|
|
||||||
var globalSettingFolder = os.Getenv("HOME") + "/Library/Application Support"
|
|
||||||
var cacheFolder = os.Getenv("HOME") + "/Library/Caches"
|
|
8
vendor/github.com/shibukawa/configdir/config_windows.go
generated
vendored
8
vendor/github.com/shibukawa/configdir/config_windows.go
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
package configdir
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
var hasVendorName = true
|
|
||||||
var systemSettingFolders = []string{os.Getenv("PROGRAMDATA")}
|
|
||||||
var globalSettingFolder = os.Getenv("APPDATA")
|
|
||||||
var cacheFolder = os.Getenv("LOCALAPPDATA")
|
|
34
vendor/github.com/shibukawa/configdir/config_xdg.go
generated
vendored
34
vendor/github.com/shibukawa/configdir/config_xdg.go
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
// +build !windows,!darwin
|
|
||||||
|
|
||||||
package configdir
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
||||||
|
|
||||||
var hasVendorName = true
|
|
||||||
var systemSettingFolders []string
|
|
||||||
var globalSettingFolder string
|
|
||||||
var cacheFolder string
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
if os.Getenv("XDG_CONFIG_HOME") != "" {
|
|
||||||
globalSettingFolder = os.Getenv("XDG_CONFIG_HOME")
|
|
||||||
} else {
|
|
||||||
globalSettingFolder = filepath.Join(os.Getenv("HOME"), ".config")
|
|
||||||
}
|
|
||||||
if os.Getenv("XDG_CONFIG_DIRS") != "" {
|
|
||||||
systemSettingFolders = strings.Split(os.Getenv("XDG_CONFIG_DIRS"), ":")
|
|
||||||
} else {
|
|
||||||
systemSettingFolders = []string{"/etc/xdg"}
|
|
||||||
}
|
|
||||||
if os.Getenv("XDG_CACHE_HOME") != "" {
|
|
||||||
cacheFolder = os.Getenv("XDG_CACHE_HOME")
|
|
||||||
} else {
|
|
||||||
cacheFolder = filepath.Join(os.Getenv("HOME"), ".cache")
|
|
||||||
}
|
|
||||||
}
|
|
10
vendor/vendor.json
vendored
10
vendor/vendor.json
vendored
@ -272,12 +272,6 @@
|
|||||||
"revision": "9eb9d2cc851389624c52a8407f8249e52ef0fc61",
|
"revision": "9eb9d2cc851389624c52a8407f8249e52ef0fc61",
|
||||||
"revisionTime": "2020-01-02T15:33:49Z"
|
"revisionTime": "2020-01-02T15:33:49Z"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"checksumSHA1": "aRFS3vu2wJRT6NZ2qUM+ubj8lhQ=",
|
|
||||||
"path": "github.com/shibukawa/configdir",
|
|
||||||
"revision": "e180dbdc8da04c4fa04272e875ce64949f38bd3e",
|
|
||||||
"revisionTime": "2017-03-30T08:48:43Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"checksumSHA1": "l9aorcNX+ngbWQFkMbuPhscH8fM=",
|
"checksumSHA1": "l9aorcNX+ngbWQFkMbuPhscH8fM=",
|
||||||
"path": "github.com/tidwall/gjson",
|
"path": "github.com/tidwall/gjson",
|
||||||
@ -343,10 +337,6 @@
|
|||||||
"path": "golang.org/x/text/language",
|
"path": "golang.org/x/text/language",
|
||||||
"revision": "929e72ca90deac4784bbe451caf10faa5b256ebe",
|
"revision": "929e72ca90deac4784bbe451caf10faa5b256ebe",
|
||||||
"revisionTime": "2019-11-14T14:00:43Z"
|
"revisionTime": "2019-11-14T14:00:43Z"
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "https://github.com/shibukawa/configdir",
|
|
||||||
"revision": ""
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rootPath": "github.com/fanaticscripter/annie-mingui"
|
"rootPath": "github.com/fanaticscripter/annie-mingui"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user