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

Side by Side Diff: src/cmd/godoc/filesystem.go

Issue 4750047: code review 4750047: godoc: implement http.FileSystem for zip files (Closed)
Patch Set: diff -r 85ab018b6c97 https://go.googlecode.com/hg/ Created 12 years, 8 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:
View unified diff | Download patch
« no previous file with comments | « src/cmd/godoc/Makefile ('k') | src/cmd/godoc/godoc.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 // This file defines types for abstract file system access and 5 // This file defines types for abstract file system access and
6 // provides an implementation accessing the file system of the 6 // provides an implementation accessing the file system of the
7 // underlying OS. 7 // underlying OS.
8 8
9 package main 9 package main
10 10
11 import ( 11 import (
12 "fmt" 12 "fmt"
13 "io" 13 "io"
14 "io/ioutil" 14 "io/ioutil"
15 "os" 15 "os"
16 ) 16 )
17 17
18 // The FileInfo interface provides access to file information. 18 // The FileInfo interface provides access to file information.
19 type FileInfo interface { 19 type FileInfo interface {
20 Name() string 20 Name() string
21 Size() int64 21 Size() int64
22 Mtime_ns() int64
22 IsRegular() bool 23 IsRegular() bool
23 IsDirectory() bool 24 IsDirectory() bool
24 } 25 }
25 26
26 // The FileSystem interface specifies the methods godoc is using 27 // The FileSystem interface specifies the methods godoc is using
27 // to access the file system for which it serves documentation. 28 // to access the file system for which it serves documentation.
28 type FileSystem interface { 29 type FileSystem interface {
29 Open(path string) (io.ReadCloser, os.Error) 30 Open(path string) (io.ReadCloser, os.Error)
30 Lstat(path string) (FileInfo, os.Error) 31 Lstat(path string) (FileInfo, os.Error)
31 Stat(path string) (FileInfo, os.Error) 32 Stat(path string) (FileInfo, os.Error)
(...skipping 15 matching lines...) Expand all
47 return fi.FileInfo.Name 48 return fi.FileInfo.Name
48 } 49 }
49 50
50 func (fi osFI) Size() int64 { 51 func (fi osFI) Size() int64 {
51 if fi.IsDirectory() { 52 if fi.IsDirectory() {
52 return 0 53 return 0
53 } 54 }
54 return fi.FileInfo.Size 55 return fi.FileInfo.Size
55 } 56 }
56 57
58 func (fi osFI) Mtime_ns() int64 {
59 return fi.FileInfo.Mtime_ns
60 }
61
57 // osFS is the OS-specific implementation of FileSystem 62 // osFS is the OS-specific implementation of FileSystem
58 type osFS struct{} 63 type osFS struct{}
59 64
60 func (osFS) Open(path string) (io.ReadCloser, os.Error) { 65 func (osFS) Open(path string) (io.ReadCloser, os.Error) {
61 f, err := os.Open(path) 66 f, err := os.Open(path)
62 if err != nil { 67 if err != nil {
63 return nil, err 68 return nil, err
64 } 69 }
65 fi, err := f.Stat() 70 fi, err := f.Stat()
66 if err != nil { 71 if err != nil {
(...skipping 23 matching lines...) Expand all
90 l1 := make([]FileInfo, len(l0)) 95 l1 := make([]FileInfo, len(l0))
91 for i, e := range l0 { 96 for i, e := range l0 {
92 l1[i] = osFI{e} 97 l1[i] = osFI{e}
93 } 98 }
94 return l1, nil 99 return l1, nil
95 } 100 }
96 101
97 func (osFS) ReadFile(path string) ([]byte, os.Error) { 102 func (osFS) ReadFile(path string) ([]byte, os.Error) {
98 return ioutil.ReadFile(path) 103 return ioutil.ReadFile(path)
99 } 104 }
OLDNEW
« no previous file with comments | « src/cmd/godoc/Makefile ('k') | src/cmd/godoc/godoc.go » ('j') | no next file with comments »

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