diff --git a/README.md b/README.md index c987a608df3b5a934314ff50203daf050eff6e8b..ead73c18cca5061edca9c3acc2c5300993041bbf 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ The real documentation is in `go doc` format. This is in csv format. For gnuplot, do not forget to `set datafile separator ','`. # BUGS +## Real Bugs + +Only under windows: I use os.Create() to open a file for writing. In my "Documents" folder, the function call returns "The system cannot find the file specified". Note, this is when creating a file, not opening an existing one. I do not have any error when I run the program from a different directory. I did experiment with chmod() on the directory, but this (a) did not do anything and (b) only the bits set by 0200 are actually affected according to go's documentation. + +## Non bugs + The UI toolkit is "fyne". It does not do charts, so we use go-chart which makes a png, which we can store in memory and feed to the fyne toolkit. Unfortunately, an svg file from go-chart causes fyne to choke. This means we are stuck with png. One day, one should try out the charting library which is based on fyne. The graphical interface follows no known style convention and looks like it was designed by a three-year old. diff --git a/mc_work/dorun.go b/mc_work/dorun.go index b3d338dc13996db3239d52c3b7d67c57142898b4..3fca29565f94e92807505b0c41c5fa5d83d8fe45 100644 --- a/mc_work/dorun.go +++ b/mc_work/dorun.go @@ -79,14 +79,12 @@ func fExists(name string) bool { } // createFix is a wrapper around os.Create() which I seem to need for windows. -// On windows, I cannot overwrite an existing file. To be very exact, the -// O_CREATE fails if a file exists. O_TRUNC also fails. -// Doing an open on the file gives the same, "The system cannot find the file specified" -// The calls fail, even if the file does not exist. It must be a problem -// with permissions on the directory, not the file. +// On windows, this fails if I am in my "Documents" directory. func createFix(name string) (*os.File, error) { - longErr := `%s does not exist, but could not create it. -Tried setting pemissions on directory %s, but failed: + longErr := `%s does not exist, but could not create it: +%w +Please run the program from somewhere other than %s` + existErr := `File exists, but unable to write to it: %w` var f *os.File var err error @@ -94,20 +92,18 @@ Tried setting pemissions on directory %s, but failed: return f, nil // Most common path (no problem) } if !fExists(name) { // does not exist, but we have a problem. - var t string - if t, err = filepath.Abs(name); err != nil { - return nil, fmt.Errorf("cannot work out path %w", err) + var d string + if t, e := filepath.Abs(name); e != nil { + return nil, fmt.Errorf("cannot work out path %w", e) + } else { + d = filepath.Dir(t) } - d := filepath.Dir(t) - e := os.Chmod(d, 0200) - if e != nil { - return nil, fmt.Errorf(longErr, name, d, e) + if _, e := os.Stat(d); e != nil { + return nil, fmt.Errorf("parent directory %s is broken %w", d, err) } - - } else { // the file exists - fmt.Println("file exists, what to do ?") + return nil, fmt.Errorf(longErr, name, err, d) } - return nil, err + return nil, fmt.Errorf(existErr, err) // The file exists.. } // setupRun does things like get the cooling rate, seed the random numbers.