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

dir

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

type Child interface {
	Parents() []*Directory
	Path() string
}

Child is an interface for the child of a directory

type Directory

type Directory struct {
	Name     string
	Parent   *Directory
	Children []Child
}

Directory ...

func CurrentDirectory

func CurrentDirectory() (d *Directory, err error)

CurrentDirectory returns a pointer to the current directory

func NewDirectory

func NewDirectory(name string) *Directory

NewDirectory returns a pointer to a directory object with a specified name

func (*Directory) AddDirectory

func (d *Directory) AddDirectory(dir *Directory) *Directory

AddDirectory adds a child directory to a directory

func (*Directory) AddDirectoryName

func (d *Directory) AddDirectoryName(s string) *Directory

AddDirectoryName adds a child directory with a specified name to a directory

func (*Directory) AddFile

func (d *Directory) AddFile(f *File)

AddFile adds a file to a directory

func (*Directory) AllChildren

func (d *Directory) AllChildren() (c []Child)

AllChildren recurses the a directories children and returns a slice of children

func (*Directory) Parents

func (d *Directory) Parents() (s []*Directory)

Parents impements Child and returns all the parents of a directory

func (*Directory) Path

func (d *Directory) Path() string

Path impements Child and returns the full path to a directory

func (*Directory) String

func (d *Directory) String() string

String implements Stringer and returns the name of a directory

func (*Directory) WithParent added in v0.1.3

func (d *Directory) WithParent(parent *Directory) *Directory

WithParent returns a pointer to a Directory from an existing Directory with a specified parent

func (*Directory) Write

func (d *Directory) Write() error

Write writes a directory to disk

func (*Directory) WriteAll

func (d *Directory) WriteAll() error

WriteAll recurses a directory and all it's children and writes it to disk

type File

type File struct {
	Name    string
	Ext     string
	Content []byte
	Parent  *Directory
}

File ...

func NewFile

func NewFile(name string) *File

NewFile returns a pointer to a File with a specified name

func NewFilePath added in v0.1.2

func NewFilePath(path string) (f *File)

NewFilePath returns a pointer to a File from a full filepath

func (*File) FullName

func (f *File) FullName() string

String returns a formatted string of the file's name and extension

func (*File) Parents

func (f *File) Parents() (s []*Directory)

Parents impements Child and returns all the parents of a file

func (*File) Path

func (f *File) Path() string

Path impements Child and returns the full path to a file

func (*File) Read

func (f *File) Read() (err error)

Read populates the content of the file from the path

func (*File) String

func (f *File) String() string

String implements Stringer and return the full name of the file

func (*File) WithContent added in v0.1.2

func (f *File) WithContent(content []byte) *File

WithContent returns a pointer to a File from an existing file with specified contents

func (*File) WithParent added in v0.1.2

func (f *File) WithParent(parent *Directory) *File

WithParent returns a pointer to a File from an existing file with a specified parent

func (*File) Write

func (f *File) Write() error

Write writes contents of the file to disk

func (*File) WritePerm

func (f *File) WritePerm(perm os.FileMode) error

WritePerm writes contents of the file to disk with specified permissions

Jump to

Keyboard shortcuts

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