Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1886)

Delta Between Two Patch Sets: src/pkg/os/exec/lp_unix.go

Issue 5416060: code review 5416060: io: new FileInfo, FileMode types + update tree (Closed)
Left Patch Set: Created 13 years, 4 months ago
Right Patch Set: diff -r d917a203b389 https://go.googlecode.com/hg/ Created 13 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/os/dir_windows.go ('k') | src/pkg/os/exec/lp_windows.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux openbsd 5 // +build darwin freebsd linux openbsd
6 6
7 package exec 7 package exec
8 8
9 import ( 9 import (
10 "errors" 10 "errors"
11 "os" 11 "os"
12 "strings" 12 "strings"
13 ) 13 )
14 14
15 // ErrNotFound is the error resulting if a path search failed to find an executa ble file. 15 // ErrNotFound is the error resulting if a path search failed to find an executa ble file.
16 var ErrNotFound = errors.New("executable file not found in $PATH") 16 var ErrNotFound = errors.New("executable file not found in $PATH")
17 17
18 func findExecutable(file string) error { 18 func findExecutable(file string) error {
19 d, err := os.Stat(file) 19 d, err := os.Stat(file)
20 if err != nil { 20 if err != nil {
21 return err 21 return err
22 } 22 }
23 » if d.IsRegular() && d.Permission()&0111 != 0 { 23 » if m := d.Mode(); !m.IsDir() && m&0111 != 0 {
24 return nil 24 return nil
25 } 25 }
26 return os.EPERM 26 return os.EPERM
27 } 27 }
28 28
29 // LookPath searches for an executable binary named file 29 // LookPath searches for an executable binary named file
30 // in the directories named by the PATH environment variable. 30 // in the directories named by the PATH environment variable.
31 // If file contains a slash, it is tried directly and the PATH is not consulted. 31 // If file contains a slash, it is tried directly and the PATH is not consulted.
32 func LookPath(file string) (string, error) { 32 func LookPath(file string) (string, error) {
33 // NOTE(rsc): I wish we could use the Plan 9 behavior here 33 // NOTE(rsc): I wish we could use the Plan 9 behavior here
(...skipping 12 matching lines...) Expand all
46 if dir == "" { 46 if dir == "" {
47 // Unix shell semantics: path element "" means "." 47 // Unix shell semantics: path element "" means "."
48 dir = "." 48 dir = "."
49 } 49 }
50 if err := findExecutable(dir + "/" + file); err == nil { 50 if err := findExecutable(dir + "/" + file); err == nil {
51 return dir + "/" + file, nil 51 return dir + "/" + file, nil
52 } 52 }
53 } 53 }
54 return "", &Error{file, ErrNotFound} 54 return "", &Error{file, ErrNotFound}
55 } 55 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b