Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #34 from albertdev/bugfix/use-filepath-package
Browse files Browse the repository at this point in the history
Use filepath package throughout for Windows support
  • Loading branch information
FooSoft authored Dec 14, 2021
2 parents 72ff784 + edb42a0 commit 0a90c2e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"path"
"path/filepath"

"github.com/naoina/toml"
"gopkg.in/yaml.v2"
Expand All @@ -50,7 +50,7 @@ func newConfig(filename string) (*config, error) {
}

conf := &config{handled: make(map[string]bool)}
switch path.Ext(filename) {
switch filepath.Ext(filename) {
case ".json":
if err := json.Unmarshal(bytes, &conf); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions homemaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
)

Expand All @@ -43,7 +43,7 @@ const (
)

func usage() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] conf src\n", path.Base(os.Args[0]))
fmt.Fprintf(os.Stderr, "Usage: %s [options] conf src\n", filepath.Base(os.Args[0]))
fmt.Fprintf(os.Stderr, "https://foosoft.net/projects/homemaker/\n\n")
fmt.Fprintf(os.Stderr, "Parameters:\n")
flag.PrintDefaults()
Expand Down
10 changes: 5 additions & 5 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strconv"
)

Expand Down Expand Up @@ -65,13 +65,13 @@ func processLink(params []string, conf *config) error {
}

srcPathAbs := srcPath
if !path.IsAbs(srcPathAbs) {
srcPathAbs = path.Join(conf.srcDir, srcPath)
if !filepath.IsAbs(srcPathAbs) {
srcPathAbs = filepath.Join(conf.srcDir, srcPath)
}

dstPathAbs := dstPath
if !path.IsAbs(dstPathAbs) {
dstPathAbs = path.Join(conf.dstDir, dstPath)
if !filepath.IsAbs(dstPathAbs) {
dstPathAbs = filepath.Join(conf.dstDir, dstPath)
}

if conf.flags&flagUnlink != flagUnlink {
Expand Down
10 changes: 5 additions & 5 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"text/template"
Expand Down Expand Up @@ -79,13 +79,13 @@ func processTemplate(params []string, conf *config) (err error) {
}

srcPathAbs := srcPath
if !path.IsAbs(srcPathAbs) {
srcPathAbs = path.Join(conf.srcDir, srcPath)
if !filepath.IsAbs(srcPathAbs) {
srcPathAbs = filepath.Join(conf.srcDir, srcPath)
}

dstPathAbs := dstPath
if !path.IsAbs(dstPathAbs) {
dstPathAbs = path.Join(conf.dstDir, dstPath)
if !filepath.IsAbs(dstPathAbs) {
dstPathAbs = filepath.Join(conf.dstDir, dstPath)
}

if _, err = os.Stat(srcPathAbs); os.IsNotExist(err) {
Expand Down
3 changes: 1 addition & 2 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
)
Expand Down Expand Up @@ -78,7 +77,7 @@ func cleanPath(loc string, flags int) (bool, error) {
}

func createPath(loc string, flags int, mode os.FileMode) error {
parentDir := path.Dir(loc)
parentDir := filepath.Dir(loc)

if _, err := os.Stat(parentDir); os.IsNotExist(err) {
if flags&flagForce != 0 || prompt("force create path", parentDir) {
Expand Down

0 comments on commit 0a90c2e

Please sign in to comment.