2024-12-27 14:43:21 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2025-01-10 04:22:53 -06:00
|
|
|
"fmt"
|
2024-12-27 14:43:21 -06:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2025-01-10 04:22:53 -06:00
|
|
|
// this file is named poorly. It has more than Sort()
|
|
|
|
|
2025-01-09 15:51:45 -06:00
|
|
|
func (pb *Files) makeNewSortfile(pf *File) error {
|
2025-01-10 04:22:53 -06:00
|
|
|
w, _ := os.OpenFile(pf.Filebase+".sort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
2024-12-27 14:43:21 -06:00
|
|
|
|
2025-01-10 04:22:53 -06:00
|
|
|
header(w, pf)
|
|
|
|
pf.syncLock(w)
|
2025-01-09 17:15:53 -06:00
|
|
|
|
|
|
|
if argv.Mutex {
|
|
|
|
// use the mutex lock from the modified protoc.pb.go file
|
|
|
|
pf.Bases.Lockname = "all.Lock"
|
2025-01-09 15:29:27 -06:00
|
|
|
}
|
|
|
|
|
2025-01-10 04:22:53 -06:00
|
|
|
pf.Base.iterTop(w)
|
|
|
|
pf.Base.iterNext(w)
|
|
|
|
pf.selectAllFunc(w)
|
|
|
|
pf.iterSelect(w)
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "// maybe seperate files here?")
|
|
|
|
|
|
|
|
pf.appendUnique(w) // Append() enforce no unique keys
|
|
|
|
pf.sortByFunc(w)
|
|
|
|
if argv.Delete {
|
|
|
|
pf.deleteWithCopyFunc(w)
|
|
|
|
} else {
|
|
|
|
pf.deleteFunc(w)
|
|
|
|
}
|
|
|
|
pf.findFunc(w)
|
2025-01-09 15:51:45 -06:00
|
|
|
return nil
|
2024-12-27 14:43:21 -06:00
|
|
|
}
|