fileIO

package module
v0.0.0-...-cd953e2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructPath

func ConstructPath(preffix, directory, fileName string) (s string)

func FilesEqual

func FilesEqual(a, b File) bool

func ReadDirectory

func ReadDirectory(dirPath string) (entries []fs.DirEntry)

This function

func RemoveAllWithinDirectory

func RemoveAllWithinDirectory(path string)

func ZipFolder

func ZipFolder(folderPath, outputName string)

func ZipFolderO

func ZipFolderO(path, output string)

Types

type CSVFile

type CSVFile struct {
	TextFile
	// contains filtered or unexported fields
}

~~~~~~~~~~~~~~~~~~~~ CSVFile

func ReadCSV

func ReadCSV(fileName string) (csv CSVFile)

returns an array of headings and a 2d array of

func (*CSVFile) GetCell

func (c *CSVFile) GetCell(row, col int) string

func (*CSVFile) GetContents

func (c *CSVFile) GetContents() [][]string

func (*CSVFile) GetIndexOfColumn

func (c *CSVFile) GetIndexOfColumn(header string) (index int)

func (*CSVFile) GetRow

func (c *CSVFile) GetRow(i int) string

func (*CSVFile) NumHeaders

func (c *CSVFile) NumHeaders() int

func (*CSVFile) Rows

func (c *CSVFile) Rows() int

type Crawler

type Crawler interface {
	HandleFile(filename os.DirEntry)
	HandleFolder(path os.DirEntry)
	Crawl(path string)
}

type File

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

func EmptyFile

func EmptyFile() *File

func NewFile

func NewFile(path, fn string) *File

func NewFileWithSuffix

func NewFileWithSuffix(fn string, suff string, path string) *File

func OpenFile

func OpenFile(path string, d os.DirEntry) (f *File)

func (*File) Append

func (f *File) Append(s string)

func (*File) AppendLine

func (f *File) AppendLine(s string)

func (*File) ClearFile

func (f *File) ClearFile()

func (*File) Contents

func (f *File) Contents() []byte

func (*File) IsEmpty

func (f *File) IsEmpty() bool

func (*File) Name

func (f *File) Name() string

func (File) Read

func (f File) Read(p []byte) (n int, err error)

copied from io.go Reader is the interface that wraps the basic Read method.

Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.

When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.

Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

If len(p) == 0, Read should always return n == 0. It may return a non-nil error if some error condition is known, such as EOF.

Implementations of Read are discouraged from returning a zero byte count with a nil error, except when len(p) == 0. Callers should treat a return of 0 and nil as indicating that nothing happened; in particular it does not indicate EOF.

Implementations must not retain p.

func (*File) String

func (f *File) String() string

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

copied from io.go Writer is the interface that wraps the basic Write method.

Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write must return a non-nil error if it returns n < len(p). Write must not modify the slice data, even temporarily.

Implementations must not retain p.

type TextFile

type TextFile struct {
	File
	// contains filtered or unexported fields
}

func NewTextFile

func NewTextFile(path, filename string) *TextFile

func NewTextFileWithSuffix

func NewTextFileWithSuffix(path, filename, suff string) *TextFile

func (*TextFile) Append

func (f *TextFile) Append(s string, newline bool)

func (*TextFile) AppendEmptyLine

func (t *TextFile) AppendEmptyLine()

func (*TextFile) AppendLastLine

func (t *TextFile) AppendLastLine(s string)

func (*TextFile) AppendLines

func (t *TextFile) AppendLines(arr []string, newline bool)

func (*TextFile) AppendNewLine

func (f *TextFile) AppendNewLine(s string)

func (*TextFile) ReadFile

func (f *TextFile) ReadFile() []string

func (*TextFile) ReadLine

func (f *TextFile) ReadLine(lineNum int) (output string, err error)

func (*TextFile) WriteLine

func (t *TextFile) WriteLine(s string, i int, newline bool)

type ZipCrawler

type ZipCrawler struct {
	ZipFile
	// contains filtered or unexported fields
}

func (*ZipCrawler) Crawl

func (c *ZipCrawler) Crawl(filename string)

func (*ZipCrawler) HandleFile

func (c *ZipCrawler) HandleFile(filename os.DirEntry)

func (*ZipCrawler) HandleFolder

func (c *ZipCrawler) HandleFolder(folderName os.DirEntry)

type ZipFile

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

~~~~~~~~~~~~~~~~~~~~ ZipFile

func EmptyZip

func EmptyZip() *ZipFile

func NewZipFile

func NewZipFile(name string) *ZipFile

func (*ZipFile) AddZipFile

func (z *ZipFile) AddZipFile(filename string, contents io.Reader)

func (*ZipFile) GetName

func (z *ZipFile) GetName() string

func (*ZipFile) WriteAndClose

func (z *ZipFile) WriteAndClose()

Jump to

Keyboard shortcuts

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