device

package
v0.0.0-...-bd9f30b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUEFINTFSSupport

func CheckUEFINTFSSupport() error

CheckUEFINTFSSupport verifies if the current system can create UEFI:NTFS partitions

func CreateProgressCmd

func CreateProgressCmd(step int, totalSteps int, stepName string, progress float64) tea.Cmd

CreateProgressCmd creates a command that sends progress updates

func FlashUSB

func FlashUSB(isoPath string, device *types.DiskUtilDevice) tea.Cmd

FlashUSB orchestrates the entire USB flashing process

func FormatDiskForUEFINTFS

func FormatDiskForUEFINTFS(name string, useGpt bool) error

FormatDiskWithUEFINTFS formats a disk with 2 partitions: - A 1 MiB FAT32 ESP partition holding UEFI:NTFS - The remaining disk is spanned by an mbr.NTFS / gpt.MicrosoftBasicData partition

func GetBlockDevicePartition

func GetBlockDevicePartition(blockDevice string, partNumber int) string

func GetFormattedDuration

func GetFormattedDuration(d time.Duration) string

GetFormattedDuration returns a human-readable duration

func GetPartitionMountPoint

func GetPartitionMountPoint(partition string) (string, error)

func InstallBootloader

func InstallBootloader(device *types.DiskUtilDevice) error

func IsUEFINTFSRequired

func IsUEFINTFSRequired(analysis *types.FilesystemAnalysis) bool

IsUEFINTFSRequired determines if UEFI:NTFS support is needed

func PrepareDevice

func PrepareDevice(device *types.DiskUtilDevice) error

func SimulateFlashingCmd

func SimulateFlashingCmd(_ string, device *types.DiskUtilDevice) tea.Cmd

SimulateFlashingCmd simulates the flashing process for demonstration

func ValidateDevice

func ValidateDevice(deviceID string) error

Linux-specific validation functions

func WriteUEFINTFSToPartition

func WriteUEFINTFSToPartition(partition string) error

Types

type AdvancedPartitionManager

type AdvancedPartitionManager struct {
	// contains filtered or unexported fields
}

AdvancedPartitionManager handles sophisticated partitioning operations

func NewAdvancedPartitionManager

func NewAdvancedPartitionManager(device string) *AdvancedPartitionManager

NewAdvancedPartitionManager creates a new partition manager

func (*AdvancedPartitionManager) CreateOptimalWindowsUSBLayout

func (pm *AdvancedPartitionManager) CreateOptimalWindowsUSBLayout(analysis *types.FilesystemAnalysis, label string) error

CreateOptimalWindowsUSBLayout creates the optimal partition layout for Windows USB

func (*AdvancedPartitionManager) CreatePartition

func (pm *AdvancedPartitionManager) CreatePartition(config *PartitionConfig) error

CreatePartition creates a partition with advanced options

func (*AdvancedPartitionManager) CreatePartitionTable

func (pm *AdvancedPartitionManager) CreatePartitionTable(tableType string) error

CreatePartitionTable creates a new partition table with proper alignment

func (*AdvancedPartitionManager) FormatPartition

func (pm *AdvancedPartitionManager) FormatPartition(partNumber int, fsType, label string) error

FormatPartition formats a partition with the specified filesystem

func (*AdvancedPartitionManager) GetPartitionInfo

func (pm *AdvancedPartitionManager) GetPartitionInfo() (map[string]interface{}, error)

GetPartitionInfo returns detailed information about the device partitions

func (*AdvancedPartitionManager) WipeDevice

func (pm *AdvancedPartitionManager) WipeDevice() error

WipeDevice completely wipes the device and verifies the operation

type AdvancedUSBCreator

type AdvancedUSBCreator struct {
	// contains filtered or unexported fields
}

AdvancedUSBCreator orchestrates the advanced Windows USB creation process

func NewAdvancedUSBCreator

func NewAdvancedUSBCreator() *AdvancedUSBCreator

NewAdvancedUSBCreator creates a new advanced USB creator

func (*AdvancedUSBCreator) Cleanup

func (creator *AdvancedUSBCreator) Cleanup()

Cleanup performs cleanup operations

func (*AdvancedUSBCreator) CreateAdvancedWindowsUSB

func (creator *AdvancedUSBCreator) CreateAdvancedWindowsUSB(config *USBCreationConfig) error

CreateAdvancedWindowsUSB performs the complete advanced Windows USB creation process

func (*AdvancedUSBCreator) GetCreationSummary

func (creator *AdvancedUSBCreator) GetCreationSummary() map[string]interface{}

GetCreationSummary returns a detailed summary of the creation process

type ConsoleProgressSubscriber

type ConsoleProgressSubscriber struct {
	// contains filtered or unexported fields
}

ConsoleProgressSubscriber implements progress updates to console

func NewConsoleProgressSubscriber

func NewConsoleProgressSubscriber() *ConsoleProgressSubscriber

NewConsoleProgressSubscriber creates a new console progress subscriber

func (*ConsoleProgressSubscriber) OnProgressUpdate

func (cps *ConsoleProgressSubscriber) OnProgressUpdate(update ProgressUpdate)

OnProgressUpdate handles progress updates for console output

type DependencyManager

type DependencyManager struct {
	// contains filtered or unexported fields
}

DependencyManager handles system dependency checking and recovery

func NewDependencyManager

func NewDependencyManager() *DependencyManager

NewDependencyManager creates a new dependency manager

func (*DependencyManager) AttemptDependencyRecovery

func (dm *DependencyManager) AttemptDependencyRecovery() error

AttemptDependencyRecovery tries to install missing dependencies automatically

func (*DependencyManager) CheckAllDependencies

func (dm *DependencyManager) CheckAllDependencies() error

CheckAllDependencies performs comprehensive dependency checking

func (*DependencyManager) CheckModernWindowsRequirements

func (dm *DependencyManager) CheckModernWindowsRequirements() []string

CheckModernWindowsRequirements validates system meets 2025 Windows requirements

func (*DependencyManager) GetSystemInfo

func (dm *DependencyManager) GetSystemInfo() map[string]interface{}

GetSystemInfo returns comprehensive system information

func (*DependencyManager) PromptForOptionalTools

func (dm *DependencyManager) PromptForOptionalTools() bool

PromptForOptionalTools asks user if they want to install optional tools for better functionality

func (*DependencyManager) WarnAboutLegacyTargetCompatibility

func (dm *DependencyManager) WarnAboutLegacyTargetCompatibility(useGPT bool, targetIsLegacy bool)

WarnAboutLegacyTargetCompatibility warns user about creating USBs for legacy systems

type DiskUtilDevice

type DiskUtilDevice struct {
	DeviceIdentifier string
	Size             int64
	Internal         bool
	MediaName        string
	MediaType        string
	RemovableMedia   bool
	WritableMedia    bool
	BusProtocol      string
	DeviceTreePath   string
	IOKitSize        int64
	VolumeName       string
	VolumeSize       int64
	MountPoint       string
	FilesystemType   string
	DeviceNode       string
}

func ListDevices

func ListDevices() ([]DiskUtilDevice, error)

func (*DiskUtilDevice) GetDeviceDescription

func (d *DiskUtilDevice) GetDeviceDescription() string

GetDeviceDescription returns a detailed description of the device

func (*DiskUtilDevice) GetDisplayName

func (d *DiskUtilDevice) GetDisplayName() string

GetDeviceDisplayName returns a human-readable name for the device

func (*DiskUtilDevice) GetSizeString

func (d *DiskUtilDevice) GetSizeString() string

GetSizeString returns a human-readable size string

type FlashProgress

type FlashProgress struct {
	Step       int
	TotalSteps int
	StepName   string
	Progress   float64
	Error      error
	Completed  bool
}

FlashProgress represents the current state of the USB flashing process

type HasExtractMethod

type HasExtractMethod interface {
	ExtractTo(path string) error
}

HasExtractMethod interface for ISO types that can extract themselves

type Operation

type Operation struct {
	ID          string
	Name        string
	Status      OperationStatus
	Progress    float64 // 0.0 to 100.0
	StartTime   time.Time
	EndTime     *time.Time
	CurrentFile string
	BytesTotal  int64
	BytesDone   int64
	Error       error
	SubOps      []*Operation
	Parent      *Operation
	// contains filtered or unexported fields
}

Operation represents a trackable operation

type OperationStatus

type OperationStatus int

OperationStatus represents the status of an operation

const (
	StatusPending OperationStatus = iota
	StatusRunning
	StatusCompleted
	StatusFailed
	StatusCanceled
)

func (OperationStatus) String

func (s OperationStatus) String() string

String returns string representation of operation status

type PartitionConfig

type PartitionConfig struct {
	Number     int
	Type       string // primary, logical, extended
	Filesystem string // fat32, ntfs, fat16
	Start      string // sector or size (e.g., "4MiB", "2048s")
	End        string // sector or size (e.g., "100%", "-2049s")
	Label      string
	Flags      []string // boot, esp, etc.
	Alignment  string   // optimal, minimal, none
}

PartitionConfig defines partition creation parameters

type ProgressSubscriber

type ProgressSubscriber interface {
	OnProgressUpdate(update ProgressUpdate)
}

ProgressSubscriber defines the interface for progress updates

type ProgressTracker

type ProgressTracker struct {
	// contains filtered or unexported fields
}

ProgressTracker manages progress reporting across multiple operations

func NewProgressTracker

func NewProgressTracker() *ProgressTracker

NewProgressTracker creates a new progress tracker

func (*ProgressTracker) AddSubOperation

func (pt *ProgressTracker) AddSubOperation(parentID, subID, subName string) *Operation

AddSubOperation adds a sub-operation to an existing operation

func (*ProgressTracker) CancelOperation

func (pt *ProgressTracker) CancelOperation(id string)

CancelOperation cancels an operation

func (*ProgressTracker) CompleteOperation

func (pt *ProgressTracker) CompleteOperation(id string)

CompleteOperation marks an operation as completed

func (*ProgressTracker) FailOperation

func (pt *ProgressTracker) FailOperation(id string, err error)

FailOperation marks an operation as failed

func (*ProgressTracker) FileProgressCallback

func (pt *ProgressTracker) FileProgressCallback(operationID string) types.FileProgressCallback

FileProgressCallback creates a callback function for file operations

func (*ProgressTracker) GetAllOperations

func (pt *ProgressTracker) GetAllOperations() map[string]*Operation

GetAllOperations returns all operations

func (*ProgressTracker) GetOperation

func (pt *ProgressTracker) GetOperation(id string) *Operation

GetOperation returns an operation by ID

func (*ProgressTracker) GetOperationSummary

func (pt *ProgressTracker) GetOperationSummary() map[string]interface{}

GetOperationSummary returns a summary of the operation status

func (*ProgressTracker) GetOverallProgress

func (pt *ProgressTracker) GetOverallProgress() float64

GetOverallProgress calculates overall progress across all operations

func (*ProgressTracker) StartOperation

func (pt *ProgressTracker) StartOperation(id, name string) *Operation

StartOperation creates and starts tracking a new operation

func (*ProgressTracker) StartPeriodicUpdates

func (pt *ProgressTracker) StartPeriodicUpdates(interval time.Duration)

StartPeriodicUpdates starts sending periodic progress updates

func (*ProgressTracker) Stop

func (pt *ProgressTracker) Stop()

Stop stops the progress tracker

func (*ProgressTracker) Subscribe

func (pt *ProgressTracker) Subscribe(subscriber ProgressSubscriber)

Subscribe adds a progress subscriber

func (*ProgressTracker) TrackOperation

func (pt *ProgressTracker) TrackOperation(id, name string, fn func() error) error

TrackOperation is a helper function to track an operation with automatic completion/failure

func (*ProgressTracker) UpdateProgress

func (pt *ProgressTracker) UpdateProgress(id string, progress float64, currentFile string, bytesDone, bytesTotal int64)

UpdateProgress updates the progress of an operation

type ProgressUpdate

type ProgressUpdate struct {
	OperationID   string
	OperationName string
	Status        OperationStatus
	Progress      float64
	CurrentFile   string
	BytesTotal    int64
	BytesDone     int64
	EstimatedTime *time.Duration
	Message       string
	Error         error
	Timestamp     time.Time
}

ProgressUpdate contains progress information

type SystemCapability

type SystemCapability struct {
	Platform           string
	CanPartition       bool
	CanFormat          bool
	CanMount           bool
	CanExtractArchives bool
	CanInstallGRUB     bool
	HasAdminRights     bool
	SupportsUEFI       bool
}

SystemCapability tracks system capabilities

type ToolRequirement

type ToolRequirement struct {
	Name         string
	Commands     []string // Alternative command names
	Purpose      string
	Installation string // Installation instructions
	Critical     bool
	MinVersion   string
	CheckVersion func(string) (string, error)
}

ToolRequirement defines requirements for a system tool

type UEFINTFSSupport

type UEFINTFSSupport struct {
	// contains filtered or unexported fields
}

UEFINTFSSupport handles UEFI:NTFS partition creation and management

func CreateUEFINTFSPartition

func CreateUEFINTFSPartition(device string) (*UEFINTFSSupport, error)

CreateUEFINTFSPartition creates a UEFI:NTFS support partition

func (*UEFINTFSSupport) CleanupUEFINTFSSupport

func (u *UEFINTFSSupport) CleanupUEFINTFSSupport() error

CleanupUEFINTFSSupport removes UEFI:NTFS partition if needed

func (*UEFINTFSSupport) GetUEFINTFSInfo

func (u *UEFINTFSSupport) GetUEFINTFSInfo() map[string]interface{}

GetUEFINTFSInfo returns information about the UEFI:NTFS setup

func (*UEFINTFSSupport) InstallBootloader

func (u *UEFINTFSSupport) InstallBootloader() error

InstallBootloader writes the UEFI:NTFS image to the partition

func (*UEFINTFSSupport) ValidateUEFINTFSPartition

func (u *UEFINTFSSupport) ValidateUEFINTFSPartition() error

ValidateUEFINTFSPartition checks if the UEFI:NTFS partition was created correctly

type USBCreationConfig

type USBCreationConfig struct {
	SourcePath      string
	TargetDevice    string
	Label           string
	ForceFilesystem types.FilesystemType
	SkipAnalysis    bool
	EnableUEFI      bool
	LegacyBIOS      bool
	QuickFormat     bool
	PerformanceMode bool
	AllowLargeFiles bool
	Verbose         bool
}

USBCreationConfig contains all configuration for USB creation

type Windows7UEFIWorkaround

type Windows7UEFIWorkaround struct {
	// contains filtered or unexported fields
}

Windows7UEFIWorkaround handles Windows 7 UEFI boot compatibility fixes

func NewWindows7UEFIWorkaround

func NewWindows7UEFIWorkaround(sourcePath, targetPath string) *Windows7UEFIWorkaround

NewWindows7UEFIWorkaround creates a new workaround instance

func (*Windows7UEFIWorkaround) Analyze

func (w *Windows7UEFIWorkaround) Analyze() error

Analyze determines if Windows 7 UEFI workaround is needed

func (*Windows7UEFIWorkaround) Apply

func (w *Windows7UEFIWorkaround) Apply() error

Apply executes the Windows 7 UEFI compatibility fix

func (*Windows7UEFIWorkaround) GetWorkaroundInfo

func (w *Windows7UEFIWorkaround) GetWorkaroundInfo() map[string]interface{}

GetWorkaroundInfo returns information about the applied workaround

func (*Windows7UEFIWorkaround) IsRequired

func (w *Windows7UEFIWorkaround) IsRequired() bool

IsRequired determines if the workaround is necessary

func (*Windows7UEFIWorkaround) ValidateWorkaround

func (w *Windows7UEFIWorkaround) ValidateWorkaround() error

ValidateWorkaround verifies that the workaround was applied correctly

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL