MCPcopy Create free account
hub / github.com/c4milo/node-inotify / callback

Function callback

example.js:8–52  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

6var data = {}; //used to correlate two events
7
8var callback = function(event) {
9 var mask = event.mask;
10 var type = mask & Inotify.IN_ISDIR ? 'directory ' : 'file ';
11 if (event.name) {
12 type += ' ' + event.name + ' ';
13 } else {
14 type += ' ';
15 }
16
17 //the porpuse of this hell of 'if'
18 //statements is only illustrative.
19
20 if (mask & Inotify.IN_ACCESS) {
21 console.log(type + 'was accessed ');
22 } else if (mask & Inotify.IN_MODIFY) {
23 console.log(type + 'was modified ');
24 } else if (mask & Inotify.IN_OPEN) {
25 console.log(type + 'was opened ');
26 } else if (mask & Inotify.IN_CLOSE_NOWRITE) {
27 console.log(type + ' opened for reading was closed ');
28 } else if (mask & Inotify.IN_CLOSE_WRITE) {
29 console.log(type + ' opened for writing was closed ');
30 } else if (mask & Inotify.IN_ATTRIB) {
31 console.log(type + 'metadata changed ');
32 } else if (mask & Inotify.IN_CREATE) {
33 console.log(type + 'created');
34 } else if (mask & Inotify.IN_DELETE) {
35 console.log(type + 'deleted');
36 } else if (mask & Inotify.IN_DELETE_SELF) {
37 console.log(type + 'watched deleted ');
38 } else if (mask & Inotify.IN_MOVE_SELF) {
39 console.log(type + 'watched moved');
40 } else if (mask & Inotify.IN_IGNORED) {
41 console.log(type + 'watch was removed');
42 } else if (mask & Inotify.IN_MOVED_FROM) {
43 data = event;
44 data.type = type;
45 } else if (mask & Inotify.IN_MOVED_TO) {
46 if ( Object.keys(data).length &&
47 data.cookie === event.cookie) {
48 console.log(type + ' moved to ' + data.type);
49 data = {};
50 }
51 }
52};
53
54var dir = {
55 path: './',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected