| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | ) |
| 7 | |
| 8 | // PickRemoteIdentityFile opens a native file dialog and returns the selected |
| 9 | // identity-file path. Browser file inputs intentionally hide absolute paths, |
| 10 | // while the SSH client needs a path that the desktop process can open. |
| 11 | func (a *App) PickRemoteIdentityFile() (string, error) { |
| 12 | if a.ctx == nil { |
| 13 | return "", nil |
| 14 | } |
| 15 | defaultDir := "" |
| 16 | if home, err := os.UserHomeDir(); err == nil { |
| 17 | defaultDir = dialogDefaultDirectory(filepath.Join(home, ".ssh")) |
| 18 | } |
| 19 | return a.nativeHost().OpenFileDialog(a.ctx, nativeDialogOptions{ |
| 20 | Title: "Choose SSH identity file", |
| 21 | DefaultDirectory: defaultDir, |
| 22 | Filters: []nativeFileFilter{ |
| 23 | {DisplayName: "SSH identity files", Pattern: "*"}, |
| 24 | }, |
| 25 | }) |
| 26 | } |
| 27 |