fspider

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 6 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)

Types

type Spider

type Spider struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

func NewSpider

func NewSpider() *Spider

func (*Spider) AllPaths added in v0.0.2

func (s *Spider) AllPaths() []string

return all paths that are being watched, this method is thread safe

func (*Spider) FilesChanged

func (s *Spider) FilesChanged() <-chan string

func (*Spider) IsSpiderable

func (s *Spider) IsSpiderable(path string) bool

to check if a path is spiderable, and this method is thread safe

func (*Spider) Spide

func (s *Spider) Spide(path string) error

use to watch a dir recursively,path can only be a dir

func (*Spider) Stop

func (s *Spider) Stop()

stop watching files, this method is thread safe

func (*Spider) UnSpide

func (s *Spider) UnSpide(path string) error

use to unwatch a dir unrecursively,path can only be a dir

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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