file

abstract fun file(path: String): ContentSource

Creates a ContentSource for path within this root.

A relative path is resolved against the root: against FileSystemSource.pathPrefix on the local file system, and against AbstractRepo.rawSourcePrefix for repositories, where the path begins with the branch name (e.g. "main/src/App.kt"). An absolute file path, or for repositories a full URL (one that starts with a scheme such as https://), is used unchanged.

No containment is applied: .. segments and absolute paths escape a FileSystemSource's directory, and a repository reads any full URL, including file: URLs and internal hosts. Validate a path that comes from user input before passing it here.

Return

a ContentSource that can be used to read the file's content

Parameters

path

the path to the file, relative to this root