Esempio n. 1
0
            public void Unsubscribe()
            {
                if (!this.is_subscribed)
                {
                    return;
                }

                Inotify.Unsubscribe(watchinfo, this);
                this.is_subscribed = false;
            }
Esempio n. 2
0
        public override void Initialize(IPlayer player)
        {
            if (!Inotify.Enabled)
            {
                return;
            }

            this.player = player;

            notify = new ThreadNotify(new ReadyEvent(OnNotify));

            foreach (string dir in player.WatchedFolders)
            {
                Watch(dir);
            }

            player.WatchedFoldersChangedEvent += OnFoldersChanged;
            Inotify.Start();
        }
Esempio n. 3
0
        /////////////////////////////////////////////////////////////////////////////////

#if INOTIFY_TEST
        static void Main(string [] args)
        {
            Queue to_watch  = new Queue();
            bool  recursive = false;

            foreach (string arg in args)
            {
                if (arg == "-r" || arg == "--recursive")
                {
                    recursive = true;
                }
                else
                {
                    // Our hashes work without a trailing path delimiter
                    string path = arg.TrimEnd('/');
                    to_watch.Enqueue(path);
                }
            }

            while (to_watch.Count > 0)
            {
                string path = (string)to_watch.Dequeue();

                Console.WriteLine("Watching {0}", path);
                Inotify.Subscribe(path, null, Inotify.EventType.All);
            }

            Inotify.Start();
            Inotify.Verbose = true;

            while (Inotify.Enabled && Inotify.WatchCount > 0)
            {
                Thread.Sleep(1000);
            }

            if (Inotify.WatchCount == 0)
            {
                Console.WriteLine("Nothing being watched.");
            }

            // Kill the event-reading thread so that we exit
            Inotify.Stop();
        }
Esempio n. 4
0
        private void Watch(string folder)
        {
            /* Do not monitor non existing directories */
            if (!Directory.Exists(folder))
            {
                return;
            }

            /* Do not monitor lost+found directories, since these
             * are not accesible to mortal users. */
            if (folder.EndsWith("lost+found"))
            {
                return;
            }

            /* Do not monitor trash folders */
            if (folder.EndsWith(".Trash"))
            {
                return;
            }

            /* Do not monitor per-user trash folders, eg. on removable
             * devices. These are * named ".Trash-username" */
            if (Path.GetFileName(folder).StartsWith(".Trash-"))
            {
                return;
            }

            Inotify.Subscribe(folder, new Inotify.InotifyCallback(OnInotifyEvent),
                              Inotify.EventType.CloseWrite | Inotify.EventType.Delete |
                              Inotify.EventType.Create | Inotify.EventType.MovedFrom |
                              Inotify.EventType.MovedTo);

            foreach (string dir in Directory.GetDirectories(folder))
            {
                Watch(dir);
            }
        }