Beispiel #1
0
        /////////////////////////////////////////////////////////////////////////////////

#if INOTIFY_TEST
        private 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);

                if (recursive)
                {
                    foreach (string subdir in DirectoryWalker.GetDirectories(path))
                    {
                        to_watch.Enqueue(subdir);
                    }
                }
            }

            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();
        }
Beispiel #2
0
        static public IEnumerable GetFileInfosRecursive(string path)
        {
            foreach (FileInfo i in DirectoryWalker.GetFileInfos(path))
            {
                yield return(i);
            }

            foreach (string dir in DirectoryWalker.GetDirectories(path))
            {
                foreach (FileInfo i in GetFileInfosRecursive(dir))
                {
                    yield return(i);
                }
            }

            yield break;
        }