file

open override fun file(path: String): UrlSource

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


fun file(path: String, connectTimeout: Duration, readTimeout: Duration): UrlSource

Creates a UrlSource for path, as file does, with the given timeouts.

Parameters

path

the path to the file, relative to this root, or a full URL

connectTimeout

the maximum time to wait for a connection

readTimeout

the maximum time to wait for data once connected