FileManager

package
v0.0.0-...-605a3a2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileAlreadyExistsInStructure = errors.New("file already exists in structure")

ErrFileAlreadyExistsInStructure is an error for the file system

View Source
var ErrFileDoesNotExist = errors.New("file doesn't exist")

ErrFileDoesNotExist is an error for the file system

View Source
var ErrFileDoesNotExistInStructure = errors.New("file doesn't exist in structure")

ErrFileDoesNotExistInStructure is an error for the file system

Functions

func DeleteFiles

func DeleteFiles(contents []*FS.File, slicePos ...int) []*FS.File

DeleteFiles will take out files from an array

func Indexfs

func Indexfs(CurrentFile *FS.File)

Indexfs will index all subdirectories if the file is a folder

func NewFile

func NewFile(path string, filetype string, previousPath string) *FS.File

NewFile is a constructor for FS.File

func PullFile

func PullFile(contents []*FS.File, name string) (*FS.File, error)

PullFile will check an array for a file by name

func UpdateInfo

func UpdateInfo(CurrentFile *FS.File)

UpdateInfo will be called to update the meta data for the file

Types

type FileManager

type FileManager struct {
	RootFolderPath string
	Structure      *FS.File
	Watcher        *fsnotify.Watcher
	// contains filtered or unexported fields
}

FileManager is an object for keeping track of a folder and it's contents.

func NewFileManager

func NewFileManager(rootPath string) (*FileManager, error)

NewFileManager will contstruct a FileManager Object

func (*FileManager) AddFile

func (fm *FileManager) AddFile(src, dst string) error

AddFile will copy a file from src to dst

func (*FileManager) AddFileToStructure

func (fm *FileManager) AddFileToStructure(path string) error

AddFileToStructure will add a file to the structure that was not previously there

func (*FileManager) DeleteFile

func (fm *FileManager) DeleteFile(path string) error

DeleteFile will delete a file at path or relative path

func (*FileManager) FSWatcher

func (fm *FileManager) FSWatcher()

FSWatcher will watch for events and handle them as they come in

func (*FileManager) GetFileByPath

func (fm *FileManager) GetFileByPath(path string) (file *FS.File, err error)

GetFileByPath This function will be given a path and it will return the correct file

func (*FileManager) GetJSONStructure

func (fm *FileManager) GetJSONStructure() ([]byte, error)

GetJSONStructure will create a JSON object of the Structure Object

func (*FileManager) GetStructure

func (fm *FileManager) GetStructure() *FS.File

GetStructure will return the structure safely

func (*FileManager) HandleCreate

func (fm *FileManager) HandleCreate(event fsnotify.Event)

HandleCreate will handle all creation events

func (*FileManager) HandleDelete

func (fm *FileManager) HandleDelete(event fsnotify.Event)

HandleDelete will handle all Rename and Delete events

func (*FileManager) HandleEvent

func (fm *FileManager) HandleEvent(event fsnotify.Event)

HandleEvent will handle a File system Event

func (*FileManager) HandleWrite

func (fm *FileManager) HandleWrite(event fsnotify.Event)

HandleWrite will handle all write events

func (*FileManager) InitPaths

func (fm *FileManager) InitPaths()

InitPaths This function will check that our Root Folder Path Exists and is created, then it will add fsnotify watchers to every path

func (*FileManager) MoveFile

func (fm *FileManager) MoveFile(src, dst string) (err error)

MoveFile will move a file from src to dst

func (*FileManager) PrintEventDetails

func (fm *FileManager) PrintEventDetails(event fsnotify.Event)

PrintEventDetails will take an event and print the event details about it. If the last op is the same it will just print a dot

func (*FileManager) PrintStructure

func (fm *FileManager) PrintStructure()

PrintStructure will dump the Structure object to the console

func (*FileManager) RemoveFileFromStructure

func (fm *FileManager) RemoveFileFromStructure(path string) error

RemoveFileFromStructure Will remove a file object from the Structure Map

Jump to

Keyboard shortcuts

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