fileselectdlg.go
func (d *FileSelectDialog) detectPath() {
	p := d.currPath
	if p == "" {
		d.currPath, _ = os.Getwd()
		return
	}

	p = filepath.Clean(p)
	for {
		_, err := os.Stat(p)
		if err == nil {
			break
		}

		dirUp := filepath.Dir(p)
		if dirUp == p {
			p, _ = os.Getwd()
			break
		}

		p = dirUp
	}
	d.currPath = p
}
func (d *FileSelectDialog) detectPath() {
	p := d.currPath
	if p == "" {
		d.currPath, _ = os.Getwd()
		return
	}

	p = filepath.Clean(p)
	for {
		_, err := os.Stat(p)
		if err == nil {
			break
		}

		dirUp := filepath.Dir(p)
		if dirUp == p {
			p, _ = os.Getwd()
			break
		}

		p = dirUp
	}
	d.currPath = p
}
func ( d * FileSelectDialog ) detectPath ( ) { p := d . currPath if p == " " { d . currPath , _ = os . Getwd ( ) return } p = filepath . Clean ( p ) for { _ , err := os . Stat ( p ) if err == nil { break } dirUp := filepath . Dir ( p ) if dirUp == p { p , _ = os . Getwd ( ) break } p = dirUp } d . currPath = p }
// Tries to find the best fit for the given path.
// It goes up until it gets into the existing directory.
// If all fails it returns working directory.
Tries to find the best fit for the given path . It goes up until it gets into the existing directory . If all fails it returns working directory .