fspider

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 7 Imported by: 1

README

fspider

项目

这是一个使用Go语言编写的文件系统监视器。它可以递归地监视指定的目录,并在文件或目录被创建、删除、修改或重命名时发送通知。

示例

package main

import (
	"github.com/cncsmonster/fspider"
)

func main() {
	spider := fspider.NewSpider()
	// add current dir to watch list
	err := spider.Watch("./")
	if err != nil {
		panic(err)
	}
	for v := range spider.FilesChanged() {
		println(v)
	}
	<-make(chan struct{})
}

License

本项目采用MIT许可证,详情请见LICENSE文件。

Documentation

Overview

/ recursively spider a program directory

Index

Constants

View Source
const (
	FS_CREATE = 1 << iota
	FS_DELETE
	FS_MODIFY
	FS_RENAME
)

event type

Variables

This section is empty.

Functions

func Log added in v0.0.2

func Log(arg ...any)

func NewPathSet added in v0.0.5

func NewPathSet() *pathSetImpl

Types

type PathSet added in v0.0.5

type PathSet interface {
	Add(string)
	Remove(string)
	Contains(string) bool
	Paths() []string
}

type Spider

type Spider interface {
	// use to watch a path
	Spide(path string) error
	// use to unwatch a path
	UnSpide(path string) error
	// return a channel that will receive all the files that have been changed(edited,or created), this method is thread safe
	FilesChanged() <-chan string
	// return all paths that are being watched, this method is thread safe
	AllPaths() []string
	// return all files that are being watched, this method is thread safe
	AllFiles() []string
	// return all dirs that are being watched, this method is thread safe
	AllDirs() []string
	// stop watching files,releasing all resources, this method is thread safe,
	// this function must be called at the end of the life cycle
	Stop()
}

func NewSpider

func NewSpider() Spider

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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