io

package
v0.0.0-...-e089fa4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFileAccessor

type DefaultFileAccessor struct {
	FileReader
	FileWriter
}

DefaultFileAccessor is the base implementation of FileAccessor

func (*DefaultFileAccessor) CreateFileFromContent

func (sr *DefaultFileAccessor) CreateFileFromContent(name string, content string)

CreateFileFromContent creates a file with the given name and extension with content

func (*DefaultFileAccessor) CreateFileFromLines

func (sr *DefaultFileAccessor) CreateFileFromLines(name string, lines []string)

CreateFileFromLines creates a file with the given name and extension and lines as content

func (*DefaultFileAccessor) FindPaths

func (sr *DefaultFileAccessor) FindPaths(root, pattern string) ([]string, error)

FindPaths returns all file paths from the given root path, if it is a file path, it will return it as a slice

func (*DefaultFileAccessor) ReadCode

func (sr *DefaultFileAccessor) ReadCode(name string) string

ReadCode reads the code lines from a source file into a string array. It will ignore all of the empty lines and the comments. It will give back the line numbers in the files in an int array, what will help later the parser to locate the error, if a there is an invalid code which can not be translated to binary.

func (*DefaultFileAccessor) ReadCodeAsLines

func (sr *DefaultFileAccessor) ReadCodeAsLines(name string) ([]string, []int)

ReadCodeAsLines reads the code lines from a source file into a string array. It will ignore all of the empty lines and the comments. It will give back the line numbers in the files in an int array, what will help later the parser to locate the error, if a there is an invalid code which can not be translated to binary.

type DefaultFileReader

type DefaultFileReader struct {
}

DefaultFileReader is the base implementation of FileReader

func (*DefaultFileReader) Read

func (sc *DefaultFileReader) Read(fileName string) ([]byte, error)

Read uses inside the ioutil.ReadFile function to read files

type DefaultFileWriter

type DefaultFileWriter struct {
}

DefaultFileWriter is the base implementation of FileWriter

func (*DefaultFileWriter) Write

func (sc *DefaultFileWriter) Write(name string, data []byte) error

Write writes the data to a file with the given file name, it creates the file if it does not exists. It truncates the file if it already exists.

type FileAccessor

type FileAccessor interface {
	ReadCodeAsLines(name string) ([]string, []int)
	ReadCode(name string) string
	CreateFileFromLines(name string, lines []string)
	CreateFileFromContent(name string, content string)
	FindPaths(root, pattern string) ([]string, error)
}

FileAccessor is an interface for reading code lines of source file and creating new files

type FileReader

type FileReader interface {
	Read(fileName string) ([]byte, error)
}

FileReader is an interface for reading files

type FileWriter

type FileWriter interface {
	Write(name string, data []byte) error
}

FileWriter is an interface for creating and writing hack file

Jump to

Keyboard shortcuts

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