Documentation
¶
Overview ¶
Package transfer provides file transfer functionality using SCP/SFTP
Index ¶
- func ExpandPath(path string) (string, error)
- func GetSSHFSInstallInstructions() string
- func IsPickerAvailable() bool
- func IsSSHFSAvailable() bool
- func ValidateLocalPath(path string, direction Direction) error
- type Direction
- type FileInfo
- type PickerMode
- type PickerResult
- func OpenFilePicker(mode PickerMode, title string, startDir string) (*PickerResult, error)
- func OpenRemoteDirectoryPicker(host, startPath, configFile string) (*PickerResult, error)
- func OpenRemoteFilePicker(host, startPath, configFile string, mode PickerMode, title string) (*PickerResult, error)
- func OpenRemoteFolderInFinder(host, startPath, configFile string) (*PickerResult, error)
- func OpenSavePicker(title string, defaultName string, startDir string) (*PickerResult, error)
- type RemoteFile
- type RunningTransfer
- type SFTPSession
- func (s *SFTPSession) Close() error
- func (s *SFTPSession) GetHomeDirectory() (string, error)
- func (s *SFTPSession) HasLocate() bool
- func (s *SFTPSession) ListDirectory(path string) ([]RemoteFile, error)
- func (s *SFTPSession) QuickSearch(pattern, startDir string, limit int) ([]RemoteFile, error)
- func (s *SFTPSession) ReadFile(path string, w io.Writer) error
- func (s *SFTPSession) Search(pattern, startDir string, limit int) ([]RemoteFile, error)
- func (s *SFTPSession) Stat(path string) (*RemoteFile, error)
- type SSHFSMount
- type TransferRequest
- type TransferResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandPath ¶
ExpandPath expands ~ to home directory and makes path absolute
func GetSSHFSInstallInstructions ¶
func GetSSHFSInstallInstructions() string
GetSSHFSInstallInstructions returns platform-specific install instructions
func IsPickerAvailable ¶
func IsPickerAvailable() bool
IsPickerAvailable checks if native file picker is available on this system
func ValidateLocalPath ¶
ValidateLocalPath checks if a local path is valid for the given direction
Types ¶
type FileInfo ¶
FileInfo represents basic file information
func GetLocalFiles ¶
GetLocalFiles returns a list of files/directories in the given path
type PickerMode ¶
type PickerMode int
PickerMode defines whether we're selecting files or directories
const ( PickFile PickerMode = iota PickDirectory PickMultiple // Multiple files )
type PickerResult ¶
type PickerResult struct {
Selected bool // True if user selected something (didn't cancel)
Path string // Single path (for PickFile/PickDirectory)
Paths []string // Multiple paths (for PickMultiple)
Directory string // The directory where selection was made
}
PickerResult contains the result of a file picker operation
func OpenFilePicker ¶
func OpenFilePicker(mode PickerMode, title string, startDir string) (*PickerResult, error)
OpenFilePicker opens the native OS file picker dialog
func OpenRemoteDirectoryPicker ¶
func OpenRemoteDirectoryPicker(host, startPath, configFile string) (*PickerResult, error)
OpenRemoteDirectoryPicker opens picker for selecting remote directory
func OpenRemoteFilePicker ¶
func OpenRemoteFilePicker(host, startPath, configFile string, mode PickerMode, title string) (*PickerResult, error)
OpenRemoteFilePicker mounts remote filesystem and opens native file picker
func OpenRemoteFolderInFinder ¶
func OpenRemoteFolderInFinder(host, startPath, configFile string) (*PickerResult, error)
OpenRemoteFolderInFinder mounts and opens Finder, returns selected path when done
func OpenSavePicker ¶
func OpenSavePicker(title string, defaultName string, startDir string) (*PickerResult, error)
OpenSavePicker opens a native save dialog to select destination
type RemoteFile ¶
RemoteFile represents a file on the remote server
type RunningTransfer ¶
type RunningTransfer struct {
// contains filtered or unexported fields
}
RunningTransfer represents a transfer that can be cancelled
func (*RunningTransfer) Cancel ¶
func (rt *RunningTransfer) Cancel()
Cancel kills the running transfer
func (*RunningTransfer) Done ¶
func (rt *RunningTransfer) Done() <-chan *TransferResult
Done returns a channel that receives the result when transfer completes
type SFTPSession ¶
type SFTPSession struct {
// contains filtered or unexported fields
}
SFTPSession manages an SFTP connection for browsing
func NewSFTPSession ¶
func NewSFTPSession(host, configFile string) (*SFTPSession, error)
NewSFTPSession creates a new SFTP session using SSH agent
func (*SFTPSession) GetHomeDirectory ¶
func (s *SFTPSession) GetHomeDirectory() (string, error)
GetHomeDirectory returns the remote home directory
func (*SFTPSession) HasLocate ¶
func (s *SFTPSession) HasLocate() bool
HasLocate checks if locate/mlocate is available on the remote system
func (*SFTPSession) ListDirectory ¶
func (s *SFTPSession) ListDirectory(path string) ([]RemoteFile, error)
ListDirectory lists files in a remote directory
func (*SFTPSession) QuickSearch ¶
func (s *SFTPSession) QuickSearch(pattern, startDir string, limit int) ([]RemoteFile, error)
QuickSearch does a faster search without fetching file details Uses timeout and depth limit to avoid slow searches
func (*SFTPSession) ReadFile ¶
func (s *SFTPSession) ReadFile(path string, w io.Writer) error
ReadFile reads a remote file (for small files only)
func (*SFTPSession) Search ¶
func (s *SFTPSession) Search(pattern, startDir string, limit int) ([]RemoteFile, error)
Search searches for files matching the pattern Uses locate if available (fast, indexed), otherwise falls back to find
func (*SFTPSession) Stat ¶
func (s *SFTPSession) Stat(path string) (*RemoteFile, error)
Stat returns file info for a remote path
type SSHFSMount ¶
SSHFSMount represents a mounted SSHFS filesystem
func NewSSHFSMount ¶
func NewSSHFSMount(host, remotePath, configFile string) (*SSHFSMount, error)
NewSSHFSMount creates a new SSHFS mount
func (*SSHFSMount) ToRemotePath ¶
func (m *SSHFSMount) ToRemotePath(localPath string) (string, error)
ToRemotePath converts a local path within the mount to a remote path
func (*SSHFSMount) Unmount ¶
func (m *SSHFSMount) Unmount() error
Unmount unmounts the remote filesystem
type TransferRequest ¶
type TransferRequest struct {
Host string // SSH host name from config
Direction Direction // Upload or Download
LocalPath string // Local file/directory path
RemotePath string // Remote file/directory path
Recursive bool // Transfer directories recursively
ConfigFile string // Optional SSH config file path
}
TransferRequest represents a file transfer request
func ParseTransferArgs ¶
func ParseTransferArgs(source, dest string) (*TransferRequest, error)
ParseTransferArgs parses scp-style arguments into a TransferRequest Examples:
- "./local.txt", "host:/remote/path" -> Upload
- "host:/remote/file.txt", "./local/" -> Download
func (*TransferRequest) BuildSCPCommand ¶
func (r *TransferRequest) BuildSCPCommand() *exec.Cmd
BuildSCPCommand builds the scp command for the transfer
func (*TransferRequest) Execute ¶
func (r *TransferRequest) Execute() *TransferResult
Execute runs the transfer and returns the result
func (*TransferRequest) ExecuteWithProgress ¶
func (r *TransferRequest) ExecuteWithProgress() *TransferResult
ExecuteWithProgress runs the transfer with progress callback This uses scp's built-in progress indicator
func (*TransferRequest) StartTransfer ¶
func (r *TransferRequest) StartTransfer() *RunningTransfer
StartTransfer starts a transfer and returns a RunningTransfer that can be cancelled
type TransferResult ¶
TransferResult represents the result of a transfer operation