func (d *FileSelectDialog) populateFiles() error {
	d.listBox.Clear()
	isRoot := filepath.Dir(d.currPath) == d.currPath

	if !isRoot {
		d.listBox.AddItem("..")
	}

	f, err := os.Open(d.currPath)
	if err != nil {
		return err
	}

	finfos, err := f.Readdir(0)
	f.Close()
	if err != nil {
		return err
	}

	fnLess := func(i, j int) bool {
		if finfos[i].IsDir() && !finfos[j].IsDir() {
			return true
		} else if !finfos[i].IsDir() && finfos[j].IsDir() {
			return false
		}

		return strings.ToLower(finfos[i].Name()) < strings.ToLower(finfos[j].Name())
	}

	sort.Slice(finfos, fnLess)

	for _, finfo := range finfos {
		if !d.fileFitsMask(finfo) {
			continue
		}

		if finfo.IsDir() {
			d.listBox.AddItem(finfo.Name() + string(os.PathSeparator))
		} else {
			d.listBox.AddItem(finfo.Name())
		}
	}

	return nil
}
func (d *FileSelectDialog) populateFiles() error {
	d.listBox.Clear()
	isRoot := filepath.Dir(d.currPath) == d.currPath

	if !isRoot {
		d.listBox.AddItem("..")
	}

	f, err := os.Open(d.currPath)
	if err != nil {
		return err
	}

	finfos, err := f.Readdir(0)
	f.Close()
	if err != nil {
		return err
	}

	fnLess := func(i, j int) bool {
		if finfos[i].IsDir() && !finfos[j].IsDir() {
			return true
		} else if !finfos[i].IsDir() && finfos[j].IsDir() {
			return false
		}

		return strings.ToLower(finfos[i].Name()) < strings.ToLower(finfos[j].Name())
	}

	sort.Slice(finfos, fnLess)

	for _, finfo := range finfos {
		if !d.fileFitsMask(finfo) {
			continue
		}

		if finfo.IsDir() {
			d.listBox.AddItem(finfo.Name() + string(os.PathSeparator))
		} else {
			d.listBox.AddItem(finfo.Name())
		}
	}

	return nil
}
func ( d * FileSelectDialog ) populateFiles ( ) error { d . listBox . Clear ( ) isRoot := filepath . Dir ( d . currPath ) == d . currPath if ! isRoot { d . listBox . AddItem ( " " ) } f , err := os . Open ( d . currPath ) if err != nil { return err } finfos , err := f . Readdir ( 0 ) f . Close ( ) if err != nil { return err } fnLess := func ( i , j int ) bool { if finfos [ i ] . IsDir ( ) && ! finfos [ j ] . IsDir ( ) { return true } else if ! finfos [ i ] . IsDir ( ) && finfos [ j ] . IsDir ( ) { return false } return strings . ToLower ( finfos [ i ] . Name ( ) ) < strings . ToLower ( finfos [ j ] . Name ( ) ) } sort . Slice ( finfos , fnLess ) for _ , finfo := range finfos { if ! d . fileFitsMask ( finfo ) { continue } if finfo . IsDir ( ) { d . listBox . AddItem ( finfo . Name ( ) + string ( os . PathSeparator ) ) } else { d . listBox . AddItem ( finfo . Name ( ) ) } } return nil }
// Fills the ListBox with the file names from current directory.
// Files which names do not match mask are filtered out.
// If select directory is set, then the ListBox contains only directories.
// Directory names ends with path separator
Fills the ListBox with the file names from current directory . Files which names do not match mask are filtered out . If select directory is set then the ListBox contains only directories . Directory names ends with path separator