<commit_before>using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;

namespace De.Thekid.INotify
{
	// List of possible changes
	public enum Change
	{
		CREATE, MODIFY, DELETE, MOVED_FROM, MOVED_TO
	}

	/// Main class
	public class Runner
	{
		// Mappings
		protected static Dictionary<WatcherChangeTypes, Change> Changes = new Dictionary<WatcherChangeTypes, Change>();

		private List<Thread> _threads = new List<Thread>();
		private bool _eventOccured = false;
		private Semaphore _semaphore = new Semaphore(0, 1);
		private Mutex _mutex = new Mutex();
		private Arguments _args = null;

		static Runner()
		{
			Changes[WatcherChangeTypes.Created]= Change.CREATE;
			Changes[WatcherChangeTypes.Changed]= Change.MODIFY;
			Changes[WatcherChangeTypes.Deleted]= Change.DELETE;
		}

		public Runner(Arguments args)
		{
			_args = args;
		}

		/// Callback for errors in watcher
		protected void OnWatcherError(object source, ErrorEventArgs e)
		{
			Console.Error.WriteLine("*** {0}", e.GetException());
		}

		/// Output method
		protected void Output(TextWriter writer, string[] tokens, FileSystemWatcher source, Change type, string name)
		{
			foreach (var token in tokens)
			{
				switch (token[0])
				{
					case 'e':
						var path = Path.Combine(source.Path, name);
						writer.Write(type);

						if (Directory.Exists(path))
						{
							writer.Write(",ISDIR");
						}
						break;
					case 'f': writer.Write(name); break;
					case 'w': writer.Write(source.Path); break;
					case 'T': writer.Write(DateTime.Now); break;
					default: writer.Write(token); break;
				}
			}
			writer.WriteLine();
		}

		public void Processor(object data) {
			string path = (string)data;
			using (var w = new FileSystemWatcher {
				Path = path,
				IncludeSubdirectories = _args.Recursive,
				Filter = "*.*"
			}) {
				w.Error += new ErrorEventHandler(OnWatcherError);

				// Parse "events" argument
				WatcherChangeTypes changes = 0;
				if (_args.Events.Contains("create"))
				{
					changes |= WatcherChangeTypes.Created;
				}<commit_msg>Adjust path and filenames to match original . Change monitored path and the path of the notified element . Change file (or directory) name to only consist of local name See #12<commit_after>using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;

namespace De.Thekid.INotify
{
	// List of possible changes
	public enum Change
	{
		CREATE, MODIFY, DELETE, MOVED_FROM, MOVED_TO
	}

	/// Main class
	public class Runner
	{
		// Mappings
		protected static Dictionary<WatcherChangeTypes, Change> Changes = new Dictionary<WatcherChangeTypes, Change>();

		private List<Thread> _threads = new List<Thread>();
		private bool _eventOccured = false;
		private Semaphore _semaphore = new Semaphore(0, 1);
		private Mutex _mutex = new Mutex();
		private Arguments _args = null;

		static Runner()
		{
			Changes[WatcherChangeTypes.Created]= Change.CREATE;
			Changes[WatcherChangeTypes.Changed]= Change.MODIFY;
			Changes[WatcherChangeTypes.Deleted]= Change.DELETE;
		}

		public Runner(Arguments args)
		{
			_args = args;
		}

		/// Callback for errors in watcher
		protected void OnWatcherError(object source, ErrorEventArgs e)
		{
			Console.Error.WriteLine("*** {0}", e.GetException());
		}

		/// Output method
		protected void Output(TextWriter writer, string[] tokens, FileSystemWatcher source, Change type, string name)
		{
			foreach (var token in tokens)
			{
				var path = Path.Combine(source.Path, name);
				switch (token[0])
				{
					case 'e':
						writer.Write(type);
						if (Directory.Exists(path))
						{
							writer.Write(",ISDIR");
						}
						break;
					case 'f': writer.Write(Path.GetFileName(path)); break;
					case 'w': writer.Write(Path.Combine(source.Path, Path.GetDirectoryName(path))); break;
					case 'T': writer.Write(DateTime.Now); break;
					default: writer.Write(token); break;
				}
			}
			writer.WriteLine();
		}

		public void Processor(object data) {
			string path = (string)data;
			using (var w = new FileSystemWatcher {
				Path = path,
				IncludeSubdirectories = _args.Recursive,
				Filter = "*.*"
			}) {
				w.Error += new ErrorEventHandler(OnWatcherError);

				// Parse "events" argument
				WatcherChangeTypes changes = 0;
				if (_args.Events.Contains("create"))
				{
					changes |= WatcherChangeTypes.Created;
				}
{'fraction_non_alphanumeric': 0.11682987929856525, 'fraction_numerical': 0.002732862673650649, 'mean_word_length': 3.4229607250755287, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '709959', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1344, 'n_words': 360}