summaryrefslogtreecommitdiff
path: root/utils.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2019-07-05 17:33:47 +0300
committerGitHub <[email protected]>2019-07-05 17:33:47 +0300
commit2f2ff270a9f6adcef8351b1bdf5319b5d612b53f (patch)
tree0dbc83883d33ac239db651f19be3fe67fd3dc361 /utils.go
parent6ffe496ea9530c0638974624ed9dd429f9ad592e (diff)
parent72c5c945f0d5861ba1d4e51a0a5ac36a4bef3868 (diff)
Merge pull request #98 from posener/refactor
Some refactorings
Diffstat (limited to 'utils.go')
-rw-r--r--utils.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/utils.go b/utils.go
deleted file mode 100644
index 58b8b79..0000000
--- a/utils.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package complete
-
-import (
- "os"
- "path/filepath"
- "strings"
-)
-
-// fixPathForm changes a file name to a relative name
-func fixPathForm(last string, file string) string {
- // get wording directory for relative name
- workDir, err := os.Getwd()
- if err != nil {
- return file
- }
-
- abs, err := filepath.Abs(file)
- if err != nil {
- return file
- }
-
- // if last is absolute, return path as absolute
- if filepath.IsAbs(last) {
- return fixDirPath(abs)
- }
-
- rel, err := filepath.Rel(workDir, abs)
- if err != nil {
- return file
- }
-
- // fix ./ prefix of path
- if rel != "." && strings.HasPrefix(last, ".") {
- rel = "./" + rel
- }
-
- return fixDirPath(rel)
-}
-
-func fixDirPath(path string) string {
- info, err := os.Stat(path)
- if err == nil && info.IsDir() && !strings.HasSuffix(path, "/") {
- path += "/"
- }
- return path
-}