ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.
(dirname string)
| 795 | // ReadDir reads the directory named by dirname and returns |
| 796 | // a list of directory entries sorted by filename. |
| 797 | func (vfs *VFS) ReadDir(dirname string) ([]os.FileInfo, error) { |
| 798 | f, err := vfs.Open(dirname) |
| 799 | if err != nil { |
| 800 | return nil, err |
| 801 | } |
| 802 | list, err := f.Readdir(-1) |
| 803 | closeErr := f.Close() |
| 804 | if err != nil { |
| 805 | return nil, err |
| 806 | } |
| 807 | if closeErr != nil { |
| 808 | return nil, closeErr |
| 809 | } |
| 810 | sort.Slice(list, func(i, j int) bool { return list[i].Name() < list[j].Name() }) |
| 811 | return list, nil |
| 812 | } |
| 813 | |
| 814 | // ReadFile reads the file named by filename and returns the contents. |
| 815 | // A successful call returns err == nil, not err == EOF. Because ReadFile |