filewatcher 0.2.2

File Watcher Library
Documentation
  • Coverage
  • 0%
    0 out of 14 items documented0 out of 8 items with examples
  • Size
  • Source code size: 17.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kingxsp/filewatcher
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kingxsp

File Watcher

Usage

First, add the following to your Cargo.toml

[dependencies]
filewatcher = "0.2.2"

Example

extern crate filewatcher;
use filewatcher::{FileWatcher, Message};

fn main() {
	let mut times = 0;
	let mut watcher = match FileWatcher::new("Cargo.toml".to_string()) {
		Ok(w) => w,
		Err(err) => panic!("Can't read: {}", err)
	};

	let inode = watcher.get_inode();
	let mut watcher = match watcher.reposition(inode, 0) {
			Ok(w) => w,
			Err(err) => panic!("Can't reposition: {}", err)
		};

	loop {
	    match watcher.next() {
			Some(Message::NONE) => {
				println!("None None!!!");
			},
	        Some(Message::Line{inode, position, line}) => {
				println!("inode: {:?}  position: {:?} line: {:?}", inode, position, line);	
	        },
	        None => break
	    }
		
		println!("filename: {:?}", watcher.get_filename());
		println!("file inode: {:?}", watcher.get_inode());
		println!("file position: {:?}", watcher.get_position());
		
		if times == 5 {
			watcher.close();
		}
		times += 1;
	}
}