// ParseFile behaves like parser.ParseFile, // but uses the build context's file system interface, if any. // // If file is not absolute (as defined by IsAbsPath), the (dir, file) // components are joined using JoinPath; dir must be absolute. // // The displayPath function, if provided, is used to transform the // filename that will be attached to the ASTs. // // TODO(adonovan): call this from go/loader.parseFiles when the tree thaws. func ParseFile(fset *token.FileSet, ctxt *build.Context, displayPath func(string) string, dir string, file string, mode parser.Mode) (*ast.File, error) { … } // ContainingPackage returns the package containing filename. // // If filename is not absolute, it is interpreted relative to working directory dir. // All I/O is via the build context's file system interface, if any. // // The '...Files []string' fields of the resulting build.Package are not // populated (build.FindOnly mode). func ContainingPackage(ctxt *build.Context, dir, filename string) (*build.Package, error) { … } // HasSubdir calls ctxt.HasSubdir (if not nil) or else uses // the local file system to answer the question. func HasSubdir(ctxt *build.Context, root, dir string) (rel string, ok bool) { … } func hasSubdir(root, dir string) (rel string, ok bool) { … } // FileExists returns true if the specified file exists, // using the build context's file system interface. func FileExists(ctxt *build.Context, path string) bool { … } // OpenFile behaves like os.Open, // but uses the build context's file system interface, if any. func OpenFile(ctxt *build.Context, path string) (io.ReadCloser, error) { … } // IsAbsPath behaves like filepath.IsAbs, // but uses the build context's file system interface, if any. func IsAbsPath(ctxt *build.Context, path string) bool { … } // JoinPath behaves like filepath.Join, // but uses the build context's file system interface, if any. func JoinPath(ctxt *build.Context, path ...string) string { … } // IsDir behaves like os.Stat plus IsDir, // but uses the build context's file system interface, if any. func IsDir(ctxt *build.Context, path string) bool { … } // ReadDir behaves like ioutil.ReadDir, // but uses the build context's file system interface, if any. func ReadDir(ctxt *build.Context, path string) ([]os.FileInfo, error) { … } // SplitPathList behaves like filepath.SplitList, // but uses the build context's file system interface, if any. func SplitPathList(ctxt *build.Context, s string) []string { … } // sameFile returns true if x and y have the same basename and denote // the same file. func sameFile(x, y string) bool { … }