// 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")) } } }
func (a *accessControl) canWriteFile(p gopath.GoPath) bool { if p.HasErr() || !p.IsRegular() { return false } return a.hasWorldWritePermission(p.FileMode()) }
func (a *accessControl) canEnterDirectory(p gopath.GoPath) bool { if p.HasErr() || !p.IsDirectory() { return false } return a.hasWorldExecutePermission(p.FileMode()) }