NewEngine creates an Engine that writes to the given writers. workspaceRoot defines the boundary for path validation; empty defaults to cwd.
(out, errOut io.Writer, workspaceRoot string)
| 114 | // NewEngine creates an Engine that writes to the given writers. |
| 115 | // workspaceRoot defines the boundary for path validation; empty defaults to cwd. |
| 116 | func NewEngine(out, errOut io.Writer, workspaceRoot string) *Engine { |
| 117 | root := workspaceRoot |
| 118 | if root == "" { |
| 119 | if wd, err := os.Getwd(); err == nil { |
| 120 | root = wd |
| 121 | } |
| 122 | } |
| 123 | return &Engine{Out: out, Err: errOut, WorkspaceRoot: root} |
| 124 | } |
| 125 | |
| 126 | // validatePath checks that a file path is within the workspace boundary and not sensitive. |
| 127 | func (e *Engine) validatePath(target string) error { |
no outgoing calls