Documentation
¶
Index ¶
- func InitSudoClient(appPath, askPass string)
- func IsTerminalRunnable(ctx context.Context, v VFS, path string) bool
- func RegisterProvider(p VFSProvider)
- func RunSudoAskpass()
- func RunSudoDispatcher(sockPath string)
- type App
- type FastScanner
- type HostAPI
- type NullVFS
- func (v *NullVFS) Abs(p string) (string, error)
- func (v *NullVFS) Base(p string) string
- func (v *NullVFS) Clone() VFS
- func (v *NullVFS) Close() error
- func (v *NullVFS) Create(ctx context.Context, p string) (io.WriteCloser, error)
- func (v *NullVFS) Dir(p string) string
- func (v *NullVFS) GetCapabilities() VFSCapabilities
- func (v *NullVFS) GetPath() string
- func (v *NullVFS) IsAtRoot() bool
- func (v *NullVFS) Join(elem ...string) string
- func (v *NullVFS) MkDir(ctx context.Context, p string) error
- func (v *NullVFS) Open(ctx context.Context, p string) (ReadAtCloser, error)
- func (v *NullVFS) ParentVFS() VFS
- func (v *NullVFS) ReadDir(ctx context.Context, p string, onChunk func([]VFSItem)) error
- func (v *NullVFS) Remove(ctx context.Context, p string) error
- func (v *NullVFS) Rename(ctx context.Context, old, new string) error
- func (v *NullVFS) Search(ctx context.Context, p string, pattern string) (chan int64, error)
- func (v *NullVFS) SetAttributes(ctx context.Context, path string, item VFSItem) error
- func (v *NullVFS) SetPath(p string) error
- func (v *NullVFS) Stat(ctx context.Context, p string) (VFSItem, error)
- type OSVFS
- func (v *OSVFS) Abs(path string) (string, error)
- func (v *OSVFS) Base(path string) string
- func (v *OSVFS) Clone() VFS
- func (v *OSVFS) Close() error
- func (v *OSVFS) Create(ctx context.Context, path string) (io.WriteCloser, error)
- func (v *OSVFS) Dir(path string) string
- func (v *OSVFS) GetCapabilities() VFSCapabilities
- func (v *OSVFS) GetPath() string
- func (v *OSVFS) IsAtRoot() bool
- func (v *OSVFS) Join(elem ...string) string
- func (v *OSVFS) MkDir(ctx context.Context, path string) error
- func (v *OSVFS) Open(ctx context.Context, path string) (ReadAtCloser, error)
- func (v *OSVFS) ParentVFS() VFS
- func (v *OSVFS) ReadDir(ctx context.Context, path string, onChunk func([]VFSItem)) error
- func (v *OSVFS) Remove(ctx context.Context, path string) error
- func (v *OSVFS) Rename(ctx context.Context, old, new string) error
- func (v *OSVFS) Search(ctx context.Context, path string, pattern string) (chan int64, error)
- func (v *OSVFS) SetAttributes(ctx context.Context, path string, item VFSItem) error
- func (v *OSVFS) SetPath(path string) error
- func (v *OSVFS) Stat(ctx context.Context, path string) (VFSItem, error)
- type OpStats
- type PtyProvider
- type ReadAtCloser
- type ScanCallback
- type SudoClient
- func (c *SudoClient) Connect() error
- func (c *SudoClient) IsAvailable() bool
- func (c *SudoClient) MkDir(path string, mode uint32) error
- func (c *SudoClient) Open(path string, flags int, mode uint32) (*os.File, error)
- func (c *SudoClient) ReadDir(path string) ([]VFSItem, error)
- func (c *SudoClient) Remove(path string) error
- func (c *SudoClient) Rename(oldPath, newPath string) error
- func (c *SudoClient) RunOnUI(fn func())
- func (c *SudoClient) SendRequest(req SudoRequest) (SudoResponse, *os.File, error)
- func (c *SudoClient) SetAttributes(path string, item VFSItem) error
- func (c *SudoClient) Stat(path string) (VFSItem, error)
- type SudoCommand
- type SudoRequest
- type SudoResponse
- type TempFileWrapper
- type VFS
- type VFSCapabilities
- type VFSItem
- type VFSProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitSudoClient ¶
func InitSudoClient(appPath, askPass string)
InitSudoClient initializes the global SudoClient.
func IsTerminalRunnable ¶
IsTerminalRunnable checks if a file can be executed in the built-in terminal.
func RegisterProvider ¶
func RegisterProvider(p VFSProvider)
func RunSudoAskpass ¶
func RunSudoAskpass()
RunSudoAskpass is executed when f4 is called with --askpass flag by sudo -A. It connects back to the main f4 process to get the password from the UI.
func RunSudoDispatcher ¶
func RunSudoDispatcher(sockPath string)
RunSudoDispatcher starts the elevated backend server loop. It is spawned by SudoClient via `sudo -A`.
Types ¶
type App ¶
type App interface {
GetActivePanelVFS() VFS
GetPassivePanelVFS() VFS
GetSelectedNames() []string
GetSelectedName() string
RefreshAll()
RunProgressTask(title, startMsg string, forked bool, worker func(ctx context.Context, update func(msg string, percent int)) error, onComplete func(err error))
// UI Bridge
Message(title, msg string, buttons []string) int
InputBox(title, prompt, history string, callback func(string))
Menu(title string, items []string, callback func(int))
}
App defines the interface for plugin-to-core UI interactions.
type FastScanner ¶
type FastScanner interface {
Scan(ctx context.Context, basePath string, names []string, cb ScanCallback) (OpStats, error)
}
FastScanner is an optional interface for VFS implementations. If a VFS implements this, it means it can offload the tree traversal to the remote server (e.g., FISH+), drastically reducing network roundtrips.
type HostAPI ¶
type HostAPI interface {
GetVersion() string
Log(msg string)
Message(msg string)
RegisterHighlighter(p vtui.HighlighterProvider)
RegisterVFSProvider(p VFSProvider)
RegisterDrive(name string, factory func() VFS)
RegisterGlobalHotkey(vk uint16, mods vtinput.ControlKeyState, handler func(app App))
RegisterPluginMenuItem(label string, handler func(app App))
}
HostAPI defines the functions f4 exposes to plugins.
type NullVFS ¶
type NullVFS struct {
// contains filtered or unexported fields
}
NullVFS is a mock filesystem for testing UI responsiveness and file operations. It provides virtual files of specific sizes and discards any written data, simulating network or disk delays via a speed limit.
func NewNullVFS ¶
NewNullVFS creates a new NullVFS with the specified speed limit in bytes per second.
func (*NullVFS) GetCapabilities ¶
func (v *NullVFS) GetCapabilities() VFSCapabilities
func (*NullVFS) SetAttributes ¶
type OSVFS ¶
type OSVFS struct {
// contains filtered or unexported fields
}
func (*OSVFS) GetCapabilities ¶
func (v *OSVFS) GetCapabilities() VFSCapabilities
func (*OSVFS) SetAttributes ¶
type OpStats ¶
OpStats holds detailed statistics about a file system subtree. Separating Files/Dirs from Bytes allows for highly accurate, non-linear ETA calculations during I/O operations.
func CalculateStats ¶
func CalculateStats(ctx context.Context, v VFS, basePath string, names []string, cb ScanCallback) (OpStats, error)
CalculateStats is the main entry point for gathering operation statistics. It uses FastScanner if available, otherwise falls back to GenericScan.
func GenericScan ¶
func GenericScan(ctx context.Context, v VFS, basePath string, names []string, cb ScanCallback) (OpStats, error)
GenericScan performs a recursive, client-side tree traversal to gather stats.
type PtyProvider ¶
PtyProvider allows a VFS to provide its own PTY implementation (e.g. an SSH session for remote systems).
type ReadAtCloser ¶
type ReadAtCloser interface {
ReadAt(ctx context.Context, p []byte, off int64) (n int, err error)
Read(ctx context.Context, p []byte) (n int, err error)
io.Closer
Size() int64
} // TempFileWrapper is a helper for VFS that need to extract files to temp storage.
ReadAtCloser combines reader interfaces with context support.
type ScanCallback ¶
ScanCallback is used to report progress during a long scanning operation. It returns the path currently being inspected and the accumulated stats so far.
type SudoClient ¶
type SudoClient struct {
// contains filtered or unexported fields
}
SudoClient manages a persistent connection to the elevated f4 dispatcher.
func (*SudoClient) Connect ¶
func (c *SudoClient) Connect() error
Connect attempts to start the elevated dispatcher via sudo and connect to its socket.
func (*SudoClient) IsAvailable ¶
func (c *SudoClient) IsAvailable() bool
IsAvailable checks if the SudoClient has been initialized.
func (*SudoClient) Open ¶
Open uses SudoClient to securely fetch a File Descriptor to a protected file.
func (*SudoClient) Remove ¶
func (c *SudoClient) Remove(path string) error
func (*SudoClient) Rename ¶
func (c *SudoClient) Rename(oldPath, newPath string) error
func (*SudoClient) RunOnUI ¶
func (c *SudoClient) RunOnUI(fn func())
Dummy for SudoClient to satisfy RunOnUI if not imported
func (*SudoClient) SendRequest ¶
func (c *SudoClient) SendRequest(req SudoRequest) (SudoResponse, *os.File, error)
SendRequest sends a command to the dispatcher and waits for the response.
func (*SudoClient) SetAttributes ¶
func (c *SudoClient) SetAttributes(path string, item VFSItem) error
type SudoCommand ¶
type SudoCommand byte
const ( CmdPing SudoCommand = iota CmdOpen CmdCreate CmdStat CmdReadDir CmdMkDir CmdRemove CmdRename CmdSetAttributes )
type SudoRequest ¶
type SudoResponse ¶
type TempFileWrapper ¶
func (*TempFileWrapper) Size ¶
func (w *TempFileWrapper) Size() int64
type VFS ¶
type VFS interface {
IsAtRoot() bool
GetPath() string
SetPath(path string) error
ReadDir(ctx context.Context, path string, onChunk func([]VFSItem)) error
Stat(ctx context.Context, path string) (VFSItem, error)
Join(elem ...string) string
Abs(path string) (string, error)
Base(path string) string
Dir(path string) string
// Mutations
MkDir(ctx context.Context, path string) error
Remove(ctx context.Context, path string) error
Rename(ctx context.Context, oldpath, newpath string) error
// Advanced / Remote Operations
GetCapabilities() VFSCapabilities
Search(ctx context.Context, path string, pattern string) (chan int64, error)
// Random Access (required for high-performance Viewer/Editor)
// Open returns a ReadAtCloser for the file.
Open(ctx context.Context, path string) (ReadAtCloser, error)
// Create returns a WriteCloser for new files.
Create(ctx context.Context, path string) (io.WriteCloser, error)
// SetAttributes updates file metadata (mode, ownership, times)
SetAttributes(ctx context.Context, path string, item VFSItem) error
ParentVFS() VFS // Returns the underlying VFS if this is a virtual mount, or nil
Clone() VFS
Close() error
}
VFS is the core interface for file operations in f4.
type VFSCapabilities ¶
type VFSCapabilities struct {
HasServerSideCopy bool
HasServerSideMove bool
HasRandomAccess bool // Supports ReadAt
HasSearch bool // Supports server-side search
}
VFSCapabilities defines what the current VFS implementation can do efficiently.
type VFSItem ¶
type VFSItem struct {
Name string
Size int64
IsDir bool
MTime time.Time
Mode string
IsExecutable bool
IsHidden bool
// Metadata for Attributes dialog
ATime time.Time // Last Access
CTime time.Time // Creation (Win) or Status Change (Unix)
UnixMode uint32 // Raw numeric mode for chmod
Uid, Gid int // Ownership
}
VFSItem represents a generic file or directory entry.
type VFSProvider ¶
type VFSProvider interface {
Name() string
// Priority: чем выше, тем раньше провайдер опрашивается (архивы обычно имеют низкий приоритет)
Priority() int
// CanOpen возвращает true, если провайдер понимает этот путь.
// parent — текущая VFS, в которой находится объект.
CanOpen(ctx context.Context, parent VFS, path string) bool
// Open создает новый экземпляр VFS.
Open(ctx context.Context, parent VFS, path string) (VFS, error)
}
VFSProvider умеет определять, может ли он открыть путь, и создавать экземпляр VFS.
func FindProvider ¶
func FindProvider(ctx context.Context, parent VFS, path string) VFSProvider