summaryrefslogtreecommitdiff
path: root/newsort.go
blob: c226e6473c02b4ba8b2c7b820702e814e6fc769d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

import (
	"os"
)

func (pb *Files) makeNewSortfile(pf *File) error {
	f, _ := os.OpenFile(pf.Filebase+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)

	header(f, pf)
	pf.syncLock(f)

	if argv.Mutex {
		// use the mutex lock from the modified protoc.pb.go file
		pf.Bases.Lockname = "all.Lock"
	}

	pf.Base.iterTop(f)
	pf.Base.iterNext(f)
	pf.iterSelect(f)
	pf.appendUnique(f) // Append() enforce no unique keys
	pf.iterSortBy(f)
	pf.iterAll(f)
	return nil
}