Skip to content

Commit

Permalink
Reverting PWD change as discussed
Browse files Browse the repository at this point in the history
We await the full solution in PR #1108
  • Loading branch information
andydotxyz committed Jun 28, 2020
1 parent 194fc80 commit 3f05efa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
13 changes: 2 additions & 11 deletions dialog/file.go
Expand Up @@ -268,21 +268,12 @@ func (f *fileDialog) setSelected(file *fileDialogItem) {
//
// Order of precedence is:
//
// * os.Getwd()
// * os.UserHomeDir()
// * "/" (should be filesystem root on all supported platforms)
func (f *FileDialog) effectiveStartingDir() string {

// Try to use CWD
var err error = nil
dir, err := os.Getwd()
if err == nil {
return dir
}
fyne.LogError("Could not load CWD", err)

// fail over to home dir
dir, err = os.UserHomeDir()
// Try home dir
dir, err := os.UserHomeDir()
if err == nil {
return dir
}
Expand Down
11 changes: 4 additions & 7 deletions dialog/file_test.go
Expand Up @@ -40,19 +40,16 @@ func comparePaths(t *testing.T, p1, p2 string) bool {
}

func TestEffectiveStartingDir(t *testing.T) {
wd, err := os.Getwd()
home, err := os.UserHomeDir()
if err != nil {
t.Skipf("os.Getwd() failed, cannot run this test on this system (error getting ./), error was '%s'", err)
t.Skipf("os.UserHomeDir) failed, cannot run this test on this system, error was '%s'", err)
}

dialog := &FileDialog{}

// test that we get ./ when running with the default struct values
// test that we get $HOME when running with the default struct values
res := dialog.effectiveStartingDir()
expect := wd
if err != nil {
t.Skipf("os.Getwd() failed, cannot run this test on this system, error was '%s'", err)
}
expect := home
if !comparePaths(t, res, expect) {
t.Errorf("Expected effectiveStartingDir() to be '%s', but it was '%s'",
expect, res)
Expand Down

0 comments on commit 3f05efa

Please sign in to comment.