f5d5f487eb
Add a function to make a directory and intervening directories, honoring core.sharedRepository. To do so, add a utility function to perform an operation with the umask set to a certain value. This is required because os.MkdirAll honors the umask and is potentially recursive (so we can't fix things after creating them). Without temporarily setting the umask, it isn't possible to create directories with the right permissions if those permissions are looser than the original umask.
12 lines
173 B
Go
12 lines
173 B
Go
// +build !windows
|
|
|
|
package tools
|
|
|
|
import "syscall"
|
|
|
|
func doWithUmask(mask int, f func() error) error {
|
|
mask = syscall.Umask(mask)
|
|
defer syscall.Umask(mask)
|
|
return f()
|
|
}
|