Skip to content

Commit

Permalink
updated API
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanisham committed Apr 10, 2024
1 parent 554d478 commit 137e0db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions cli/meta/symlink_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// "bytes"
"errors"
"os"
"runtime"

// "os/exec"
"strings"
Expand Down Expand Up @@ -54,21 +53,21 @@ func isAdmin() bool {
func Symlink(oldname, newname string) error {

// Check if already admin first
if runtime.GOOS == "windows" && isAdmin() {
if isAdmin() {
if err := os.Symlink(oldname, newname); err != nil {
return errors.Join(ErrEscalatedSymlink, err)
}
return nil
}

// If not already admin, try to become admin
if runtime.GOOS == "windows" && !isAdmin() {
} else {
// If not already admin, try to become admin
if err := becomeAdmin(); err != nil {
if err := os.Symlink(oldname, newname); err != nil {
return errors.Join(ErrEscalatedSymlink, err)
}
}
}



return nil
}
5 changes: 3 additions & 2 deletions cli/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bufio"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -40,8 +41,8 @@ func (z *ZVM) setBin(ver string) error {
bin_dir := filepath.Join(z.baseDir, "bin")

// Remove "bin" dir only if it already exists
_, err := os.Stat(bin_dir)
if !os.IsNotExist(err) {

if _, err := os.Stat(bin_dir); errors.Is(err, fs.ErrExist) {
fmt.Printf("Removing old %s", bin_dir)
if err := os.Remove(bin_dir); err != nil {
return err
Expand Down

0 comments on commit 137e0db

Please sign in to comment.