]> Cypherpunks repositories - gostls13.git/commitdiff
rename os.Dir to os.FileInfo
authorRob Pike <r@golang.org>
Fri, 9 Apr 2010 18:36:40 +0000 (11:36 -0700)
committerRob Pike <r@golang.org>
Fri, 9 Apr 2010 18:36:40 +0000 (11:36 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/902042

14 files changed:
src/cmd/godoc/godoc.go
src/cmd/godoc/index.go
src/cmd/gofmt/gofmt.go
src/pkg/go/parser/interface.go
src/pkg/go/parser/parser_test.go
src/pkg/io/ioutil/ioutil.go
src/pkg/os/file.go
src/pkg/os/stat_darwin.go
src/pkg/os/stat_linux.go
src/pkg/os/stat_mingw.go
src/pkg/os/stat_nacl.go
src/pkg/os/types.go
src/pkg/path/path.go
src/pkg/path/path_test.go

index f302f8c7e9a9e29b205ad334e51cf2814a5ca348..9c59db287abdeec82d5d3604e5caea4e1b0d6caf 100644 (file)
@@ -116,21 +116,21 @@ func registerPublicHandlers(mux *http.ServeMux) {
 // ----------------------------------------------------------------------------
 // Predicates and small utility functions
 
-func isGoFile(dir *os.Dir) bool {
-       return dir.IsRegular() &&
-               !strings.HasPrefix(dir.Name, ".") && // ignore .files
-               pathutil.Ext(dir.Name) == ".go"
+func isGoFile(f *os.FileInfo) bool {
+       return f.IsRegular() &&
+               !strings.HasPrefix(f.Name, ".") && // ignore .files
+               pathutil.Ext(f.Name) == ".go"
 }
 
 
-func isPkgFile(dir *os.Dir) bool {
-       return isGoFile(dir) &&
-               !strings.HasSuffix(dir.Name, "_test.go") // ignore test files
+func isPkgFile(f *os.FileInfo) bool {
+       return isGoFile(f) &&
+               !strings.HasSuffix(f.Name, "_test.go") // ignore test files
 }
 
 
-func isPkgDir(dir *os.Dir) bool {
-       return dir.IsDirectory() && len(dir.Name) > 0 && dir.Name[0] != '_'
+func isPkgDir(f *os.FileInfo) bool {
+       return f.IsDirectory() && len(f.Name) > 0 && f.Name[0] != '_'
 }
 
 
@@ -789,7 +789,7 @@ func timeFmt(w io.Writer, x interface{}, format string) {
 
 // Template formatter for "dir/" format.
 func dirslashFmt(w io.Writer, x interface{}, format string) {
-       if x.(*os.Dir).IsDirectory() {
+       if x.(*os.FileInfo).IsDirectory() {
                w.Write([]byte{'/'})
        }
 }
@@ -1196,7 +1196,7 @@ type httpHandler struct {
 //
 func (h *httpHandler) getPageInfo(abspath, relpath, pkgname string, mode PageInfoMode) PageInfo {
        // filter function to select the desired .go files
-       filter := func(d *os.Dir) bool {
+       filter := func(d *os.FileInfo) bool {
                // If we are looking at cmd documentation, only accept
                // the special fakePkgFile containing the documentation.
                return isPkgFile(d) && (h.isPkg || d.Name == fakePkgFile)
index a2c71c97bd1daf591c2645ac2e2c6a00db4a5a82..481519c66fe3a890199862790b9f5220ae3b64cd 100644 (file)
@@ -578,17 +578,17 @@ func (x *Indexer) Visit(node interface{}) ast.Visitor {
 }
 
 
-func (x *Indexer) VisitDir(path string, d *os.Dir) bool {
+func (x *Indexer) VisitDir(path string, f *os.FileInfo) bool {
        return true
 }
 
 
-func (x *Indexer) VisitFile(path string, d *os.Dir) {
-       if !isGoFile(d) {
+func (x *Indexer) VisitFile(path string, f *os.FileInfo) {
+       if !isGoFile(f) {
                return
        }
 
-       if excludeTestFiles && (!isPkgFile(d) || strings.HasPrefix(path, "test/")) {
+       if excludeTestFiles && (!isPkgFile(f) || strings.HasPrefix(path, "test/")) {
                return
        }
 
index abd30edc89b6c9f6635813e43e2beebcb599395f..ffec0325fed57879d96f98ce7b64af38297770ee 100644 (file)
@@ -80,9 +80,9 @@ func initPrinterMode() {
 }
 
 
-func isGoFile(d *os.Dir) bool {
+func isGoFile(f *os.FileInfo) bool {
        // ignore non-Go files
-       return d.IsRegular() && !strings.HasPrefix(d.Name, ".") && strings.HasSuffix(d.Name, ".go")
+       return f.IsRegular() && !strings.HasPrefix(f.Name, ".") && strings.HasSuffix(f.Name, ".go")
 }
 
 
@@ -145,13 +145,13 @@ func processFileByName(filename string) (err os.Error) {
 
 type fileVisitor chan os.Error
 
-func (v fileVisitor) VisitDir(path string, d *os.Dir) bool {
+func (v fileVisitor) VisitDir(path string, f *os.FileInfo) bool {
        return true
 }
 
 
-func (v fileVisitor) VisitFile(path string, d *os.Dir) {
-       if isGoFile(d) {
+func (v fileVisitor) VisitFile(path string, f *os.FileInfo) {
+       if isGoFile(f) {
                v <- nil // synchronize error handler
                if err := processFileByName(path); err != nil {
                        v <- err
index fcaa3dfdff0d63888f23f8f6ddf4c20a5da1822d..e1ddb37c3046ce719d63b5b45c5f198edfe48933 100644 (file)
@@ -173,14 +173,14 @@ func ParseFiles(filenames []string, scope *ast.Scope, mode uint) (map[string]*as
 
 // ParseDir calls ParseFile for the files in the directory specified by path and
 // returns a map of package name -> package AST with all the packages found. If
-// filter != nil, only the files with os.Dir entries passing through the filter
+// filter != nil, only the files with os.FileInfo entries passing through the filter
 // are considered. The mode bits are passed to ParseFile unchanged.
 //
 // If the directory couldn't be read, a nil map and the respective error are
 // returned. If a parse error occured, a non-nil but incomplete map and the
 // error are returned.
 //
-func ParseDir(path string, filter func(*os.Dir) bool, mode uint) (map[string]*ast.Package, os.Error) {
+func ParseDir(path string, filter func(*os.FileInfo) bool, mode uint) (map[string]*ast.Package, os.Error) {
        fd, err := os.Open(path, os.O_RDONLY, 0)
        if err != nil {
                return nil, err
index f3b91a930faa5405e0e3dee186163f8233ab3b6d..75ebd8cec7200d2b8de86bb9184881c11d3b6425 100644 (file)
@@ -79,7 +79,7 @@ func nameFilter(filename string) bool {
 }
 
 
-func dirFilter(d *os.Dir) bool { return nameFilter(d.Name) }
+func dirFilter(f *os.FileInfo) bool { return nameFilter(f.Name) }
 
 
 func TestParse4(t *testing.T) {
index ebdcf224f75aa7b440f0875d2cb598e8491d1e71..0f5a3a20ef523b36e1a9e0e67c62388e0363211b 100644 (file)
@@ -27,12 +27,12 @@ func ReadFile(filename string) ([]byte, os.Error) {
                return nil, err
        }
        defer f.Close()
-       // It's a good but not certain bet that Stat will tell us exactly how much to
+       // It's a good but not certain bet that FileInfo will tell us exactly how much to
        // read, so let's try it but be prepared for the answer to be wrong.
-       dir, err := f.Stat()
+       fi, err := f.Stat()
        var n uint64
-       if err == nil && dir.Size < 2e9 { // Don't preallocate a huge buffer, just in case.
-               n = dir.Size
+       if err == nil && fi.Size < 2e9 { // Don't preallocate a huge buffer, just in case.
+               n = fi.Size
        }
        // Add a little extra in case Size is zero, and to avoid another allocation after
        // Read has filled the buffer.
@@ -63,15 +63,15 @@ func WriteFile(filename string, data []byte, perm int) os.Error {
 }
 
 // A dirList implements sort.Interface.
-type dirList []*os.Dir
+type fileInfoList []*os.FileInfo
 
-func (d dirList) Len() int           { return len(d) }
-func (d dirList) Less(i, j int) bool { return d[i].Name < d[j].Name }
-func (d dirList) Swap(i, j int)      { d[i], d[j] = d[j], d[i] }
+func (f fileInfoList) Len() int           { return len(f) }
+func (f fileInfoList) Less(i, j int) bool { return f[i].Name < f[j].Name }
+func (f fileInfoList) Swap(i, j int)      { f[i], f[j] = f[j], f[i] }
 
 // ReadDir reads the directory named by dirname and returns
 // a list of sorted directory entries.
-func ReadDir(dirname string) ([]*os.Dir, os.Error) {
+func ReadDir(dirname string) ([]*os.FileInfo, os.Error) {
        f, err := os.Open(dirname, os.O_RDONLY, 0)
        if err != nil {
                return nil, err
@@ -81,10 +81,10 @@ func ReadDir(dirname string) ([]*os.Dir, os.Error) {
        if err != nil {
                return nil, err
        }
-       dirs := make(dirList, len(list))
+       fi := make(fileInfoList, len(list))
        for i := range list {
-               dirs[i] = &list[i]
+               fi[i] = &list[i]
        }
-       sort.Sort(dirs)
-       return dirs, nil
+       sort.Sort(fi)
+       return fi, nil
 }
index e79c2cdde8bf3882301a8dee31e4966c88506d5a..561f36c919ee9e5fd8a5238c0f9f84321d394f69 100644 (file)
@@ -258,12 +258,12 @@ func Mkdir(name string, perm int) Error {
        return nil
 }
 
-// Stat returns a Dir structure describing the named file and an error, if any.
-// If name names a valid symbolic link, the returned Dir describes
-// the file pointed at by the link and has dir.FollowedSymlink set to true.
-// If name names an invalid symbolic link, the returned Dir describes
-// the link itself and has dir.FollowedSymlink set to false.
-func Stat(name string) (dir *Dir, err Error) {
+// Stat returns a FileInfo structure describing the named file and an error, if any.
+// If name names a valid symbolic link, the returned FileInfo describes
+// the file pointed at by the link and has fi.FollowedSymlink set to true.
+// If name names an invalid symbolic link, the returned FileInfo describes
+// the link itself and has fi.FollowedSymlink set to false.
+func Stat(name string) (fi *FileInfo, err Error) {
        var lstat, stat syscall.Stat_t
        e := syscall.Lstat(name, &lstat)
        if e != 0 {
@@ -276,38 +276,39 @@ func Stat(name string) (dir *Dir, err Error) {
                        statp = &stat
                }
        }
-       return dirFromStat(name, new(Dir), &lstat, statp), nil
+       return fileInfoFromStat(name, new(FileInfo), &lstat, statp), nil
 }
 
-// Stat returns the Dir structure describing file.
-// It returns the Dir and an error, if any.
-func (file *File) Stat() (dir *Dir, err Error) {
+// Stat returns the FileInfo structure describing file.
+// It returns the FileInfo and an error, if any.
+func (file *File) Stat() (fi *FileInfo, err Error) {
        var stat syscall.Stat_t
        e := syscall.Fstat(file.fd, &stat)
        if e != 0 {
                return nil, &PathError{"stat", file.name, Errno(e)}
        }
-       return dirFromStat(file.name, new(Dir), &stat, &stat), nil
+       return fileInfoFromStat(file.name, new(FileInfo), &stat, &stat), nil
 }
 
-// Lstat returns the Dir structure describing the named file and an error, if any.
-// If the file is a symbolic link, the returned Dir describes the
-// symbolic link.  Lstat makes no attempt to follow the link.
-func Lstat(name string) (dir *Dir, err Error) {
+// Lstat returns the FileInfo structure describing the named file and an
+// error, if any.  If the file is a symbolic link, the returned FileInfo
+// describes the symbolic link.  Lstat makes no attempt to follow the link.
+func Lstat(name string) (fi *FileInfo, err Error) {
        var stat syscall.Stat_t
        e := syscall.Lstat(name, &stat)
        if e != 0 {
                return nil, &PathError{"lstat", name, Errno(e)}
        }
-       return dirFromStat(name, new(Dir), &stat, &stat), nil
+       return fileInfoFromStat(name, new(FileInfo), &stat, &stat), nil
 }
 
 // Readdir reads the contents of the directory associated with file and
-// returns an array of up to count Dir structures, as would be returned
-// by Stat, in directory order.  Subsequent calls on the same file will yield further Dirs.
+// returns an array of up to count FileInfo structures, as would be returned
+// by Stat, in directory order.  Subsequent calls on the same file will yield
+// further FileInfos.
 // A negative count means to read until EOF.
 // Readdir returns the array and an Error, if any.
-func (file *File) Readdir(count int) (dirs []Dir, err Error) {
+func (file *File) Readdir(count int) (fi []FileInfo, err Error) {
        dirname := file.name
        if dirname == "" {
                dirname = "."
@@ -317,13 +318,13 @@ func (file *File) Readdir(count int) (dirs []Dir, err Error) {
        if err1 != nil {
                return nil, err1
        }
-       dirs = make([]Dir, len(names))
+       fi = make([]FileInfo, len(names))
        for i, filename := range names {
-               dirp, err := Lstat(dirname + filename)
-               if dirp == nil || err != nil {
-                       dirs[i].Name = filename // rest is already zeroed out
+               fip, err := Lstat(dirname + filename)
+               if fip == nil || err != nil {
+                       fi[i].Name = filename // rest is already zeroed out
                } else {
-                       dirs[i] = *dirp
+                       fi[i] = *fip
                }
        }
        return
index 003a4535162a5ec9700a1f390d660d3c899cdeec..5ab2c39dfc07e3824d8e9803e5dd12b010b63e44 100644 (file)
@@ -10,29 +10,29 @@ func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode&syscall.S_IFMT == syscall.S_IFLNK
 }
 
-func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
-       dir.Dev = uint64(stat.Dev)
-       dir.Ino = stat.Ino
-       dir.Nlink = uint64(stat.Nlink)
-       dir.Mode = uint32(stat.Mode)
-       dir.Uid = stat.Uid
-       dir.Gid = stat.Gid
-       dir.Rdev = uint64(stat.Rdev)
-       dir.Size = uint64(stat.Size)
-       dir.Blksize = uint64(stat.Blksize)
-       dir.Blocks = uint64(stat.Blocks)
-       dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atimespec))
-       dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtimespec))
-       dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctimespec))
+func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *FileInfo {
+       fi.Dev = uint64(stat.Dev)
+       fi.Ino = stat.Ino
+       fi.Nlink = uint64(stat.Nlink)
+       fi.Mode = uint32(stat.Mode)
+       fi.Uid = stat.Uid
+       fi.Gid = stat.Gid
+       fi.Rdev = uint64(stat.Rdev)
+       fi.Size = uint64(stat.Size)
+       fi.Blksize = uint64(stat.Blksize)
+       fi.Blocks = uint64(stat.Blocks)
+       fi.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atimespec))
+       fi.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtimespec))
+       fi.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctimespec))
        for i := len(name) - 1; i >= 0; i-- {
                if name[i] == '/' {
                        name = name[i+1:]
                        break
                }
        }
-       dir.Name = name
+       fi.Name = name
        if isSymlink(lstat) && !isSymlink(stat) {
-               dir.FollowedSymlink = true
+               fi.FollowedSymlink = true
        }
-       return dir
+       return fi
 }
index 362fae48bebb2bf89352eab647055b7e10ebc050..5d3b9ee99c01e1daa42683b459a4c25b7590ff3e 100644 (file)
@@ -10,29 +10,29 @@ func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode&syscall.S_IFMT == syscall.S_IFLNK
 }
 
-func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
-       dir.Dev = stat.Dev
-       dir.Ino = uint64(stat.Ino)
-       dir.Nlink = uint64(stat.Nlink)
-       dir.Mode = stat.Mode
-       dir.Uid = stat.Uid
-       dir.Gid = stat.Gid
-       dir.Rdev = stat.Rdev
-       dir.Size = uint64(stat.Size)
-       dir.Blksize = uint64(stat.Blksize)
-       dir.Blocks = uint64(stat.Blocks)
-       dir.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atim))
-       dir.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtim))
-       dir.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctim))
+func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *FileInfo {
+       fi.Dev = stat.Dev
+       fi.Ino = uint64(stat.Ino)
+       fi.Nlink = uint64(stat.Nlink)
+       fi.Mode = stat.Mode
+       fi.Uid = stat.Uid
+       fi.Gid = stat.Gid
+       fi.Rdev = stat.Rdev
+       fi.Size = uint64(stat.Size)
+       fi.Blksize = uint64(stat.Blksize)
+       fi.Blocks = uint64(stat.Blocks)
+       fi.Atime_ns = uint64(syscall.TimespecToNsec(stat.Atim))
+       fi.Mtime_ns = uint64(syscall.TimespecToNsec(stat.Mtim))
+       fi.Ctime_ns = uint64(syscall.TimespecToNsec(stat.Ctim))
        for i := len(name) - 1; i >= 0; i-- {
                if name[i] == '/' {
                        name = name[i+1:]
                        break
                }
        }
-       dir.Name = name
+       fi.Name = name
        if isSymlink(lstat) && !isSymlink(stat) {
-               dir.FollowedSymlink = true
+               fi.FollowedSymlink = true
        }
-       return dir
+       return fi
 }
index 13a78389184e611291148c55b8de77029ccd1b4f..8e2c73cebf4fa32cf35ec13f209ee82e41ff4d65 100644 (file)
@@ -10,6 +10,6 @@ func isSymlink(stat *syscall.Stat_t) bool {
        panic("windows isSymlink not implemented")
 }
 
-func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
-       panic("windows dirFromStat not implemented")
+func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *FileInfo {
+       panic("windows fileInfoFromStat not implemented")
 }
index 65f49c8860f2e7469cf69541255064014067f807..be693e81478c90b694e270a91628cfb3ab611251 100644 (file)
@@ -10,29 +10,29 @@ func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode&syscall.S_IFMT == syscall.S_IFLNK
 }
 
-func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir {
-       dir.Dev = uint64(stat.Dev)
-       dir.Ino = uint64(stat.Ino)
-       dir.Nlink = uint64(stat.Nlink)
-       dir.Mode = stat.Mode
-       dir.Uid = stat.Uid
-       dir.Gid = stat.Gid
-       dir.Rdev = uint64(stat.Rdev)
-       dir.Size = uint64(stat.Size)
-       dir.Blksize = uint64(stat.Blksize)
-       dir.Blocks = uint64(stat.Blocks)
-       dir.Atime_ns = uint64(stat.Atime) * 1e9
-       dir.Mtime_ns = uint64(stat.Mtime) * 1e9
-       dir.Ctime_ns = uint64(stat.Ctime) * 1e9
+func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *FileInfo {
+       fi.Dev = uint64(stat.Dev)
+       fi.Ino = uint64(stat.Ino)
+       fi.Nlink = uint64(stat.Nlink)
+       fi.Mode = stat.Mode
+       fi.Uid = stat.Uid
+       fi.Gid = stat.Gid
+       fi.Rdev = uint64(stat.Rdev)
+       fi.Size = uint64(stat.Size)
+       fi.Blksize = uint64(stat.Blksize)
+       fi.Blocks = uint64(stat.Blocks)
+       fi.Atime_ns = uint64(stat.Atime) * 1e9
+       fi.Mtime_ns = uint64(stat.Mtime) * 1e9
+       fi.Ctime_ns = uint64(stat.Ctime) * 1e9
        for i := len(name) - 1; i >= 0; i-- {
                if name[i] == '/' {
                        name = name[i+1:]
                        break
                }
        }
-       dir.Name = name
+       fi.Name = name
        if isSymlink(lstat) && !isSymlink(stat) {
-               dir.FollowedSymlink = true
+               fi.FollowedSymlink = true
        }
-       return dir
+       return fi
 }
index 673b7f788f01851fc54ec3be35ccc2359e963e5b..4194ea1772a4db0e192fda9e035391abca7933ec 100644 (file)
@@ -12,8 +12,8 @@ import "syscall"
 // Getpagesize returns the underlying system's memory page size.
 func Getpagesize() int { return syscall.Getpagesize() }
 
-// A Dir describes a file and is returned by Stat, Fstat, and Lstat
-type Dir struct {
+// A FileInfo describes a file and is returned by Stat, Fstat, and Lstat
+type FileInfo struct {
        Dev             uint64 // device number of file system holding file.
        Ino             uint64 // inode number.
        Nlink           uint64 // number of hard links.
@@ -31,26 +31,26 @@ type Dir struct {
        FollowedSymlink bool   // followed a symlink to get this information
 }
 
-// IsFifo reports whether the Dir describes a FIFO file.
-func (dir *Dir) IsFifo() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFIFO }
+// IsFifo reports whether the FileInfo describes a FIFO file.
+func (f *FileInfo) IsFifo() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFIFO }
 
-// IsChar reports whether the Dir describes a character special file.
-func (dir *Dir) IsChar() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFCHR }
+// IsChar reports whether the FileInfo describes a character special file.
+func (f *FileInfo) IsChar() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFCHR }
 
-// IsDirectory reports whether the Dir describes a directory.
-func (dir *Dir) IsDirectory() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFDIR }
+// IsDirectory reports whether the FileInfo describes a directory.
+func (f *FileInfo) IsDirectory() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFDIR }
 
-// IsBlock reports whether the Dir describes a block special file.
-func (dir *Dir) IsBlock() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFBLK }
+// IsBlock reports whether the FileInfo describes a block special file.
+func (f *FileInfo) IsBlock() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFBLK }
 
-// IsRegular reports whether the Dir describes a regular file.
-func (dir *Dir) IsRegular() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFREG }
+// IsRegular reports whether the FileInfo describes a regular file.
+func (f *FileInfo) IsRegular() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFREG }
 
-// IsSymlink reports whether the Dir describes a symbolic link.
-func (dir *Dir) IsSymlink() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFLNK }
+// IsSymlink reports whether the FileInfo describes a symbolic link.
+func (f *FileInfo) IsSymlink() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFLNK }
 
-// IsSocket reports whether the Dir describes a socket.
-func (dir *Dir) IsSocket() bool { return (dir.Mode & syscall.S_IFMT) == syscall.S_IFSOCK }
+// IsSocket reports whether the FileInfo describes a socket.
+func (f *FileInfo) IsSocket() bool { return (f.Mode & syscall.S_IFMT) == syscall.S_IFSOCK }
 
 // Permission returns the file permission bits.
-func (dir *Dir) Permission() int { return int(dir.Mode & 0777) }
+func (f *FileInfo) Permission() int { return int(f.Mode & 0777) }
index 71d8b42158731b565dad8da76f61524b09054f5c..86bfe64555046b7b310421e9b1201bd0968f6917 100644 (file)
@@ -143,17 +143,17 @@ func Ext(path string) string {
 // visited by Walk. The parameter path is the full path of d relative
 // to root.
 type Visitor interface {
-       VisitDir(path string, d *os.Dir) bool
-       VisitFile(path string, d *os.Dir)
+       VisitDir(path string, f *os.FileInfo) bool
+       VisitFile(path string, f *os.FileInfo)
 }
 
-func walk(path string, d *os.Dir, v Visitor, errors chan<- os.Error) {
-       if !d.IsDirectory() {
-               v.VisitFile(path, d)
+func walk(path string, f *os.FileInfo, v Visitor, errors chan<- os.Error) {
+       if !f.IsDirectory() {
+               v.VisitFile(path, f)
                return
        }
 
-       if !v.VisitDir(path, d) {
+       if !v.VisitDir(path, f) {
                return // skip directory entries
        }
 
@@ -177,12 +177,12 @@ func walk(path string, d *os.Dir, v Visitor, errors chan<- os.Error) {
 // If errors != nil, Walk sends each directory read error
 // to the channel.  Otherwise Walk discards the error.
 func Walk(root string, v Visitor, errors chan<- os.Error) {
-       d, err := os.Lstat(root)
+       f, err := os.Lstat(root)
        if err != nil {
                if errors != nil {
                        errors <- err
                }
                return // can't progress
        }
-       walk(root, d, v, errors)
+       walk(root, f, v, errors)
 }
index cd5978c1566788fb7cab7dfb318990db6aa82dd9..e2458f20c477fa99af3d2ed75acd13183d77954f 100644 (file)
@@ -224,13 +224,13 @@ func mark(name string) {
 
 type TestVisitor struct{}
 
-func (v *TestVisitor) VisitDir(path string, d *os.Dir) bool {
-       mark(d.Name)
+func (v *TestVisitor) VisitDir(path string, f *os.FileInfo) bool {
+       mark(f.Name)
        return true
 }
 
-func (v *TestVisitor) VisitFile(path string, d *os.Dir) {
-       mark(d.Name)
+func (v *TestVisitor) VisitFile(path string, f *os.FileInfo) {
+       mark(f.Name)
 }
 
 func TestWalk(t *testing.T) {