Help us shape the future of Go! Take the 2026 Go Developer Survey

filewriter

package
v0.230.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

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

Backup handles file backup operations

func NewBackup

func NewBackup(backupDir string) *Backup

NewBackup creates a new Backup writing into backupDir - the per-project runtime backups dir (~/.infer/projects/<project-slug>/backups).

func (*Backup) CleanupBackup

func (b *Backup) CleanupBackup(backupPath string) error

CleanupBackup removes a backup file

func (*Backup) CreateBackup

func (b *Backup) CreateBackup(ctx context.Context, originalPath string) (string, error)

CreateBackup creates a backup of the original file

func (*Backup) RestoreBackup

func (b *Backup) RestoreBackup(ctx context.Context, backupPath string, originalPath string) error

RestoreBackup restores a backup to the original location

type ChunkBuffer

type ChunkBuffer interface {
	WriteChunk(ctx context.Context, req ChunkWriteRequest) error
	FinalizeChunks(ctx context.Context, sessionID string, targetPath string) (*WriteResult, error)
	CleanupSession(sessionID string) error
	GetSessionInfo(sessionID string) (*ChunkSessionInfo, error)
}

ChunkBuffer defines the interface for handling chunked file writes

func NewStreamingChunkBuffer

func NewStreamingChunkBuffer(tempDir string, writer FileWriter) ChunkBuffer

NewStreamingChunkBuffer creates a new StreamingChunkBuffer

type ChunkSession

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

ChunkSession represents an active chunked writing session

type ChunkSessionInfo

type ChunkSessionInfo struct {
	SessionID   string
	TotalChunks int
	Created     bool
}

ChunkSessionInfo provides information about an active chunk session

type ChunkWriteRequest

type ChunkWriteRequest struct {
	SessionID  string
	ChunkIndex int
	Data       []byte
	IsLast     bool
}

ChunkWriteRequest represents a chunk write operation

type DefaultPathValidator

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

DefaultPathValidator validates file paths for security and accessibility

func NewPathValidator

func NewPathValidator(cfg *config.Config) *DefaultPathValidator

NewPathValidator creates a new DefaultPathValidator

func (*DefaultPathValidator) IsInSandbox

func (v *DefaultPathValidator) IsInSandbox(path string) bool

IsInSandbox reports whether the sandbox lets a tool read path.

func (*DefaultPathValidator) IsWritable

func (v *DefaultPathValidator) IsWritable(path string) bool

IsWritable checks if a path can be written to

func (*DefaultPathValidator) Validate

func (v *DefaultPathValidator) Validate(path string) error

Validate checks if a path is valid and secure for file operations

type FileWriter

type FileWriter interface {
	Write(ctx context.Context, req WriteRequest) (*WriteResult, error)
	ValidatePath(path string) error
}

FileWriter defines the interface for file writing operations

func NewSafeFileWriter

func NewSafeFileWriter(validator *DefaultPathValidator, backupManager *Backup) FileWriter

NewSafeFileWriter creates a new SafeFileWriter

type SafeFileWriter

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

SafeFileWriter implements FileWriter with atomic operations

func (*SafeFileWriter) ValidatePath

func (w *SafeFileWriter) ValidatePath(path string) error

ValidatePath validates if a path is safe for writing

func (*SafeFileWriter) Write

Write performs an atomic file write operation

type StreamingChunkBuffer

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

StreamingChunkBuffer implements ChunkBuffer with safe streaming

func (*StreamingChunkBuffer) CleanupSession

func (cm *StreamingChunkBuffer) CleanupSession(sessionID string) error

CleanupSession removes an active session and cleans up resources

func (*StreamingChunkBuffer) FinalizeChunks

func (cm *StreamingChunkBuffer) FinalizeChunks(ctx context.Context, sessionID string, targetPath string) (*WriteResult, error)

FinalizeChunks completes a chunked write session and moves to target location

func (*StreamingChunkBuffer) GetSessionInfo

func (cm *StreamingChunkBuffer) GetSessionInfo(sessionID string) (*ChunkSessionInfo, error)

GetSessionInfo returns information about an active session

func (*StreamingChunkBuffer) WriteChunk

func (cm *StreamingChunkBuffer) WriteChunk(ctx context.Context, req ChunkWriteRequest) error

WriteChunk writes a chunk to the session's temp file

type WriteRequest

type WriteRequest struct {
	Path      string
	Content   string
	Overwrite bool
	Backup    bool
}

WriteRequest represents a file write operation request

type WriteResult

type WriteResult struct {
	Path         string
	BytesWritten int64
	BackupPath   string
	Created      bool
}

WriteResult represents the result of a file write operation

Jump to

Keyboard shortcuts

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