Beispiel #1
0
// assertPathValidForWriteAccess sets the error flag when the path may not be
// opened for writing by this process.
func (i *pathIO) assertPathValidForWriteAccess(p gopath.GoPath) {
	if i.hasErr() {
		return
	}
	if p.HasErr() {
		i.setErr(p.Err())
		return
	}

	if p.IsExists() {
		if !p.IsRegular() || !isPathWriteable(p) {
			i.setErr(store.NewAccessDeniedError(fmt.Sprintf(
				"path '%s' with mode %s denotes no regular file or no writeable directory",
				p.Path(), p.FileMode())))
		}
	} else {
		var d = p.Dir()
		if !isPathWriteable(d) {
			i.setErr(store.NewAccessDeniedError(
				"parent directory of '" + p.Path() + "' is not writeable"))
		}
	}
}
Beispiel #2
0
func (a *accessControl) canWriteFile(p gopath.GoPath) bool {
	if p.HasErr() || !p.IsRegular() {
		return false
	}
	return a.hasWorldWritePermission(p.FileMode())
}