Example #1
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();
        }
Example #2
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();
        }