mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-05-20 05:40:49 -04:00
corrected archivefs Set() function so that it works in Windows
Windows volume names confused the Set() function archivefs.Async no longer exits async goroutine on errors from Path functions. exiting meant that the channels were no longer being serviced, causing GUI deadlocks
This commit is contained in:
parent
6c96b2f065
commit
7be60c0c2a
|
@ -68,12 +68,16 @@ func NewAsyncPath(setter FilenameSetter) AsyncPath {
|
|||
afs.Close()
|
||||
|
||||
case path := <-pth.Set:
|
||||
afs.Set(path)
|
||||
err := afs.Set(path)
|
||||
if err != nil {
|
||||
pth.err <- err
|
||||
continue // for loop
|
||||
}
|
||||
|
||||
entries, err := afs.List()
|
||||
if err != nil {
|
||||
pth.err <- err
|
||||
return
|
||||
continue // for loop
|
||||
}
|
||||
|
||||
pth.results <- AsyncResults{
|
||||
|
|
|
@ -223,8 +223,12 @@ func (afs *Path) List() ([]Node, error) {
|
|||
func (afs *Path) Set(path string) error {
|
||||
afs.Close()
|
||||
|
||||
// clean path and split into parts
|
||||
// clean path and and remove volume name. volume name is not something we
|
||||
// typically have to worry about in unix type systems
|
||||
path = filepath.Clean(path)
|
||||
path = strings.TrimPrefix(path, filepath.VolumeName(path))
|
||||
|
||||
// split path into parts
|
||||
lst := strings.Split(path, string(filepath.Separator))
|
||||
|
||||
// strings.Split will remove a leading filepath.Separator. we need to add
|
||||
|
@ -284,6 +288,14 @@ func (afs *Path) Set(path string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// we want the absolute path. this restores any volume name that may have
|
||||
// been trimmed off at the start of the function
|
||||
var err error
|
||||
afs.current, err = filepath.Abs(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("archivefs: set: %v", err)
|
||||
}
|
||||
|
||||
// make sure path is clean
|
||||
afs.current = filepath.Clean(path)
|
||||
|
||||
|
|
Loading…
Reference in a new issue