type RelativeTo … // AbsPath returns an absolute filesystem path for the workdir-relative path. func (r RelativeTo) AbsPath(path string) string { … } // RelPath returns a '/'-encoded path relative to the working directory (or an // absolute path if the file is outside of workdir) func (r RelativeTo) RelPath(fp string) string { … } // writeFileData writes content to the relative path, replacing the special // token $SANDBOX_WORKDIR with the relative root given by rel. It does not // trigger any file events. func writeFileData(path string, content []byte, rel RelativeTo) error { … } var isWindowsErrLockViolation … type Workdir … // NewWorkdir writes the txtar-encoded file data in txt to dir, and returns a // Workir for operating on these files using func NewWorkdir(dir string, files map[string][]byte) (*Workdir, error) { … } type fileID … func hashFile(data []byte) string { … } // RootURI returns the root URI for this working directory of this scratch // environment. func (w *Workdir) RootURI() protocol.DocumentURI { … } // AddWatcher registers the given func to be called on any file change. func (w *Workdir) AddWatcher(watcher func(context.Context, []protocol.FileEvent)) { … } // URI returns the URI to a the workdir-relative path. func (w *Workdir) URI(path string) protocol.DocumentURI { … } // URIToPath converts a uri to a workdir-relative path (or an absolute path, // if the uri is outside of the workdir). func (w *Workdir) URIToPath(uri protocol.DocumentURI) string { … } // EntireFile returns the entire extent of the file named by the workdir-relative path. func (w *Workdir) EntireFile(path string) protocol.Location { … } // ReadFile reads a text file specified by a workdir-relative path. func (w *Workdir) ReadFile(path string) ([]byte, error) { … } // RegexpSearch searches the file corresponding to path for the first position // matching re. func (w *Workdir) RegexpSearch(path string, re string) (protocol.Location, error) { … } // RemoveFile removes a workdir-relative file path and notifies watchers of the // change. func (w *Workdir) RemoveFile(ctx context.Context, path string) error { … } // WriteFiles writes the text file content to workdir-relative paths and // notifies watchers of the changes. func (w *Workdir) WriteFiles(ctx context.Context, files map[string]string) error { … } // WriteFile writes text file content to a workdir-relative path and notifies // watchers of the change. func (w *Workdir) WriteFile(ctx context.Context, path, content string) error { … } // RenameFile performs an on disk-renaming of the workdir-relative oldPath to // workdir-relative newPath, and notifies watchers of the changes. // // oldPath must either be a regular file or in the same directory as newPath. func (w *Workdir) RenameFile(ctx context.Context, oldPath, newPath string) error { … } // ListFiles returns a new sorted list of the relative paths of files in dir, // recursively. func (w *Workdir) ListFiles(dir string) ([]string, error) { … } // CheckForFileChanges walks the working directory and checks for any files // that have changed since the last poll. func (w *Workdir) CheckForFileChanges(ctx context.Context) error { … } // pollFiles updates w.files and calculates FileEvents corresponding to file // state changes since the last poll. It does not call sendEvents. func (w *Workdir) pollFiles() ([]protocol.FileEvent, error) { … }