public ChangedFileGroup() { mChangesToIgnore = new Dictionary <string, int>(); LockObject = new object(); mFileSystemWatcher = new FileSystemWatcher(); mChangedFiles = new ChangeInformation(); mDeletedFiles = new ChangeInformation(); mFileSystemWatcher.Filter = "*.*"; mFileSystemWatcher.IncludeSubdirectories = true; mFileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite | // tiled seems to save the file with a temp name like // MyFile.tmx.D1234 // then it renames it to // MyFile.tmx // We need to handle the filename changing or else Glue isn't notified of the change. // Update - only do this for TMX (see below). // Update 2 - We need to handle renames incase // the user renamed files to solve missing // file errors. Just don't handle the .glux // so we don't get double-loads. NotifyFilters.FileName | NotifyFilters.DirectoryName; mFileSystemWatcher.Deleted += new FileSystemEventHandler(HandleFileSystemDelete); mFileSystemWatcher.Changed += new FileSystemEventHandler(HandleFileSystemChange); mFileSystemWatcher.Renamed += HandleRename; }
void HandleFileSystemDelete(object sender, FileSystemEventArgs e) { string fileName = e.FullPath; ChangeInformation toAddTo = mDeletedFiles; AddChangedFileTo(fileName, toAddTo); }
void HandleFileSystemChange(object sender, FileSystemEventArgs e) { string fileName = e.FullPath; ChangeInformation toAddTo = mChangedFiles; bool wasAdded = AddChangedFileTo(fileName, toAddTo); //if(!wasAdded && FileManager.GetExtension(fileName) == "csproj") //{ // Plugins.PluginManager.ReceiveOutput($"Ignored {fileName}, {NumberOfTimesToIgnore(fileName)} left"); //} }
void HandleFileSystemDelete(object sender, FileSystemEventArgs e) { string fileName = e.FullPath; ChangeInformation toAddTo = mDeletedFiles; bool shouldIgnoreDelete = GetIfShouldIgnoreDelete(fileName); if (!shouldIgnoreDelete) { AddChangedFileTo(fileName, toAddTo); } }
public ChangedFileGroup() { mChangesToIgnore = new Dictionary <string, int>(); LockObject = new object(); mFileSystemWatcher = new FileSystemWatcher(); mChangedFiles = new ChangeInformation(); mDeletedFiles = new ChangeInformation(); mFileSystemWatcher.Filter = "*.*"; mFileSystemWatcher.IncludeSubdirectories = true; mFileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName; mFileSystemWatcher.Deleted += new FileSystemEventHandler(HandleFileSystemDelete); mFileSystemWatcher.Changed += new FileSystemEventHandler(HandleFileSystemChange); }
void HandleFileSystemChange(object sender, FileSystemEventArgs e) { string fileName = e.FullPath; bool shouldProcess = true; if (e.ChangeType == WatcherChangeTypes.Renamed) { // don't process the .glux file, that gets renamed all the time shouldProcess = FileManager.GetExtension(fileName) != "glux"; } if (shouldProcess) { ChangeInformation toAddTo = mChangedFiles; bool wasAdded = AddChangedFileTo(fileName, toAddTo); } }
private bool AddChangedFileTo(string fileName, ChangeInformation toAddTo) { bool wasAdded = false; lock (LockObject) { bool wasIgnored = TryIgnoreFileChange(fileName); if (!wasIgnored) { toAddTo.Add(fileName); if (SortDelegate != null) { toAddTo.Sort(SortDelegate); } wasAdded = true; } mLastModification = DateTime.Now; } return(wasAdded); }
private void AddChangedFileTo(string fileName, ChangeInformation toAddTo) { lock (LockObject) { bool wasIgnored = TryIgnoreFileChange(fileName); if (!wasIgnored) { toAddTo.Add(fileName); if (SortDelegate != null) { toAddTo.Sort(SortDelegate); } } mLastModification = DateTime.Now; } }
public ChangedFileGroup() { mChangesToIgnore = new Dictionary<string, int>(); LockObject = new object(); mFileSystemWatcher = new FileSystemWatcher(); mChangedFiles = new ChangeInformation(); mDeletedFiles = new ChangeInformation(); mFileSystemWatcher.Filter = "*.*"; mFileSystemWatcher.IncludeSubdirectories = true; mFileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName; mFileSystemWatcher.Deleted += new FileSystemEventHandler(HandleFileSystemDelete); mFileSystemWatcher.Changed += new FileSystemEventHandler(HandleFileSystemChange); }