Skip to content

Commit

Permalink
first steps of saving settings
Browse files Browse the repository at this point in the history
Refs #21
  • Loading branch information
dmportella committed Sep 20, 2016
1 parent 14ecc08 commit b21dae7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/edsm/edsmplugin_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// NewPlugin creates a new instance of EDSMPlugin.
func NewPlugin(qilbot *bot.Qilbot) (plugin *Plugin) {
const (
Name = "EDSM Plugin"
Name = "Qilbot EDSM Plugin"
Description = "Client plugin for Elite Dangerous Star Map web site."
)

Expand Down
28 changes: 28 additions & 0 deletions utilities/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package utilities

import (
"io/ioutil"
"os"
)

// DefaultPermissions Permissions for file and directory creations.
const (
DefaultPermissions = 644
)

// FileOrDirectoryExists Check is a file or directory exists.
func FileOrDirectoryExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return true, err
}

// SaveToFile Saves a byte array to a path.
func SaveToFile(data []byte, path string) error {
return ioutil.WriteFile(path, data, DefaultPermissions)
}

0 comments on commit b21dae7

Please sign in to comment.