Documentation ¶
Index ¶
- Variables
- func DeleteFiles(contents []*FS.File, slicePos ...int) []*FS.File
- func Indexfs(CurrentFile *FS.File)
- func NewFile(path string, filetype string, previousPath string) *FS.File
- func PullFile(contents []*FS.File, name string) (*FS.File, error)
- func UpdateInfo(CurrentFile *FS.File)
- type FileManager
- func (fm *FileManager) AddFile(src, dst string) error
- func (fm *FileManager) AddFileToStructure(path string) error
- func (fm *FileManager) DeleteFile(path string) error
- func (fm *FileManager) FSWatcher()
- func (fm *FileManager) GetFileByPath(path string) (file *FS.File, err error)
- func (fm *FileManager) GetJSONStructure() ([]byte, error)
- func (fm *FileManager) GetStructure() *FS.File
- func (fm *FileManager) HandleCreate(event fsnotify.Event)
- func (fm *FileManager) HandleDelete(event fsnotify.Event)
- func (fm *FileManager) HandleEvent(event fsnotify.Event)
- func (fm *FileManager) HandleWrite(event fsnotify.Event)
- func (fm *FileManager) InitPaths()
- func (fm *FileManager) MoveFile(src, dst string) (err error)
- func (fm *FileManager) PrintEventDetails(event fsnotify.Event)
- func (fm *FileManager) PrintStructure()
- func (fm *FileManager) RemoveFileFromStructure(path string) error
Constants ¶
This section is empty.
Variables ¶
var ErrFileAlreadyExistsInStructure = errors.New("file already exists in structure")
ErrFileAlreadyExistsInStructure is an error for the file system
var ErrFileDoesNotExist = errors.New("file doesn't exist")
ErrFileDoesNotExist is an error for the file system
var ErrFileDoesNotExistInStructure = errors.New("file doesn't exist in structure")
ErrFileDoesNotExistInStructure is an error for the file system
Functions ¶
func DeleteFiles ¶
DeleteFiles will take out files from an array
func UpdateInfo ¶
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