756 lines
27 KiB
C#
756 lines
27 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading;
|
|
|
|
namespace System.IO
|
|
{
|
|
/// <summary>Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x02000116 RID: 278
|
|
[IODescription("")]
|
|
[global::System.ComponentModel.DefaultEvent("Changed")]
|
|
public class FileSystemWatcher : global::System.ComponentModel.Component, global::System.ComponentModel.ISupportInitialize
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.IO.FileSystemWatcher" /> class.</summary>
|
|
// Token: 0x060009E8 RID: 2536 RVA: 0x0001AF9C File Offset: 0x0001919C
|
|
public FileSystemWatcher()
|
|
{
|
|
this.notifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
this.enableRaisingEvents = false;
|
|
this.filter = "*.*";
|
|
this.includeSubdirectories = false;
|
|
this.internalBufferSize = 8192;
|
|
this.path = string.Empty;
|
|
this.InitWatcher();
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.IO.FileSystemWatcher" /> class, given the specified directory to monitor.</summary>
|
|
/// <param name="path">The directory to monitor, in standard or Universal Naming Convention (UNC) notation. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null. </exception>
|
|
/// <exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is an empty string ("").-or- The path specified through the <paramref name="path" /> parameter does not exist. </exception>
|
|
// Token: 0x060009E9 RID: 2537 RVA: 0x0001AFEC File Offset: 0x000191EC
|
|
public FileSystemWatcher(string path)
|
|
: this(path, "*.*")
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.IO.FileSystemWatcher" /> class, given the specified directory and type of files to monitor.</summary>
|
|
/// <param name="path">The directory to monitor, in standard or Universal Naming Convention (UNC) notation. </param>
|
|
/// <param name="filter">The type of files to watch. For example, "*.txt" watches for changes to all text files. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null.-or- The <paramref name="filter" /> parameter is null. </exception>
|
|
/// <exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is an empty string ("").-or- The path specified through the <paramref name="path" /> parameter does not exist. </exception>
|
|
// Token: 0x060009EA RID: 2538 RVA: 0x0001AFFC File Offset: 0x000191FC
|
|
public FileSystemWatcher(string path, string filter)
|
|
{
|
|
if (path == null)
|
|
{
|
|
throw new ArgumentNullException("path");
|
|
}
|
|
if (filter == null)
|
|
{
|
|
throw new ArgumentNullException("filter");
|
|
}
|
|
if (path == string.Empty)
|
|
{
|
|
throw new ArgumentException("Empty path", "path");
|
|
}
|
|
if (!Directory.Exists(path))
|
|
{
|
|
throw new ArgumentException("Directory does not exists", "path");
|
|
}
|
|
this.enableRaisingEvents = false;
|
|
this.filter = filter;
|
|
this.includeSubdirectories = false;
|
|
this.internalBufferSize = 8192;
|
|
this.notifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
this.path = path;
|
|
this.synchronizingObject = null;
|
|
this.InitWatcher();
|
|
}
|
|
|
|
/// <summary>Occurs when a file or directory in the specified <see cref="P:System.IO.FileSystemWatcher.Path" /> is changed.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x1400001D RID: 29
|
|
// (add) Token: 0x060009EC RID: 2540 RVA: 0x0001B0B4 File Offset: 0x000192B4
|
|
// (remove) Token: 0x060009ED RID: 2541 RVA: 0x0001B0D0 File Offset: 0x000192D0
|
|
[IODescription("Occurs when a file/directory change matches the filter")]
|
|
public event FileSystemEventHandler Changed;
|
|
|
|
/// <summary>Occurs when a file or directory in the specified <see cref="P:System.IO.FileSystemWatcher.Path" /> is created.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x1400001E RID: 30
|
|
// (add) Token: 0x060009EE RID: 2542 RVA: 0x0001B0EC File Offset: 0x000192EC
|
|
// (remove) Token: 0x060009EF RID: 2543 RVA: 0x0001B108 File Offset: 0x00019308
|
|
[IODescription("Occurs when a file/directory creation matches the filter")]
|
|
public event FileSystemEventHandler Created;
|
|
|
|
/// <summary>Occurs when a file or directory in the specified <see cref="P:System.IO.FileSystemWatcher.Path" /> is deleted.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x1400001F RID: 31
|
|
// (add) Token: 0x060009F0 RID: 2544 RVA: 0x0001B124 File Offset: 0x00019324
|
|
// (remove) Token: 0x060009F1 RID: 2545 RVA: 0x0001B140 File Offset: 0x00019340
|
|
[IODescription("Occurs when a file/directory deletion matches the filter")]
|
|
public event FileSystemEventHandler Deleted;
|
|
|
|
/// <summary>Occurs when the internal buffer overflows.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x14000020 RID: 32
|
|
// (add) Token: 0x060009F2 RID: 2546 RVA: 0x0001B15C File Offset: 0x0001935C
|
|
// (remove) Token: 0x060009F3 RID: 2547 RVA: 0x0001B178 File Offset: 0x00019378
|
|
[global::System.ComponentModel.Browsable(false)]
|
|
public event ErrorEventHandler Error;
|
|
|
|
/// <summary>Occurs when a file or directory in the specified <see cref="P:System.IO.FileSystemWatcher.Path" /> is renamed.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x14000021 RID: 33
|
|
// (add) Token: 0x060009F4 RID: 2548 RVA: 0x0001B194 File Offset: 0x00019394
|
|
// (remove) Token: 0x060009F5 RID: 2549 RVA: 0x0001B1B0 File Offset: 0x000193B0
|
|
[IODescription("Occurs when a file/directory rename matches the filter")]
|
|
public event RenamedEventHandler Renamed;
|
|
|
|
// Token: 0x060009F6 RID: 2550 RVA: 0x0001B1CC File Offset: 0x000193CC
|
|
private void InitWatcher()
|
|
{
|
|
object obj = FileSystemWatcher.lockobj;
|
|
lock (obj)
|
|
{
|
|
if (FileSystemWatcher.watcher == null)
|
|
{
|
|
string environmentVariable = Environment.GetEnvironmentVariable("MONO_MANAGED_WATCHER");
|
|
int num = 0;
|
|
if (environmentVariable == null)
|
|
{
|
|
num = FileSystemWatcher.InternalSupportsFSW();
|
|
}
|
|
bool flag = false;
|
|
switch (num)
|
|
{
|
|
case 1:
|
|
flag = DefaultWatcher.GetInstance(out FileSystemWatcher.watcher);
|
|
break;
|
|
case 2:
|
|
flag = FAMWatcher.GetInstance(out FileSystemWatcher.watcher, false);
|
|
break;
|
|
case 3:
|
|
flag = KeventWatcher.GetInstance(out FileSystemWatcher.watcher);
|
|
break;
|
|
case 4:
|
|
flag = FAMWatcher.GetInstance(out FileSystemWatcher.watcher, true);
|
|
break;
|
|
case 5:
|
|
flag = InotifyWatcher.GetInstance(out FileSystemWatcher.watcher, true);
|
|
break;
|
|
}
|
|
if (num == 0 || !flag)
|
|
{
|
|
if (string.Compare(environmentVariable, "disabled", true) == 0)
|
|
{
|
|
NullFileWatcher.GetInstance(out FileSystemWatcher.watcher);
|
|
}
|
|
else
|
|
{
|
|
DefaultWatcher.GetInstance(out FileSystemWatcher.watcher);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060009F7 RID: 2551 RVA: 0x0001B2E8 File Offset: 0x000194E8
|
|
[Conditional("TRACE")]
|
|
[Conditional("DEBUG")]
|
|
private void ShowWatcherInfo()
|
|
{
|
|
Console.WriteLine("Watcher implementation: {0}", (FileSystemWatcher.watcher == null) ? "<none>" : FileSystemWatcher.watcher.GetType().ToString());
|
|
}
|
|
|
|
// Token: 0x1700028E RID: 654
|
|
// (get) Token: 0x060009F8 RID: 2552 RVA: 0x0001B318 File Offset: 0x00019518
|
|
// (set) Token: 0x060009F9 RID: 2553 RVA: 0x0001B320 File Offset: 0x00019520
|
|
internal bool Waiting
|
|
{
|
|
get
|
|
{
|
|
return this.waiting;
|
|
}
|
|
set
|
|
{
|
|
this.waiting = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x1700028F RID: 655
|
|
// (get) Token: 0x060009FA RID: 2554 RVA: 0x0001B32C File Offset: 0x0001952C
|
|
internal string MangledFilter
|
|
{
|
|
get
|
|
{
|
|
if (this.filter != "*.*")
|
|
{
|
|
return this.filter;
|
|
}
|
|
if (this.mangledFilter != null)
|
|
{
|
|
return this.mangledFilter;
|
|
}
|
|
string text = "*.*";
|
|
if (FileSystemWatcher.watcher.GetType() != typeof(WindowsWatcher))
|
|
{
|
|
text = "*";
|
|
}
|
|
return text;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000290 RID: 656
|
|
// (get) Token: 0x060009FB RID: 2555 RVA: 0x0001B390 File Offset: 0x00019590
|
|
internal SearchPattern2 Pattern
|
|
{
|
|
get
|
|
{
|
|
if (this.pattern == null)
|
|
{
|
|
this.pattern = new SearchPattern2(this.MangledFilter);
|
|
}
|
|
return this.pattern;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000291 RID: 657
|
|
// (get) Token: 0x060009FC RID: 2556 RVA: 0x0001B3C0 File Offset: 0x000195C0
|
|
internal string FullPath
|
|
{
|
|
get
|
|
{
|
|
if (this.fullpath == null)
|
|
{
|
|
if (this.path == null || this.path == string.Empty)
|
|
{
|
|
this.fullpath = Environment.CurrentDirectory;
|
|
}
|
|
else
|
|
{
|
|
this.fullpath = global::System.IO.Path.GetFullPath(this.path);
|
|
}
|
|
}
|
|
return this.fullpath;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets a value indicating whether the component is enabled.</summary>
|
|
/// <returns>true if the component is enabled; otherwise, false. The default is false. If you are using the component on a designer in Visual Studio 2005, the default is true.</returns>
|
|
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.IO.FileSystemWatcher" /> object has been disposed.</exception>
|
|
/// <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception>
|
|
/// <exception cref="T:System.IO.FileNotFoundException">The directory specified in <see cref="P:System.IO.FileSystemWatcher.Path" /> could not be found.</exception>
|
|
/// <exception cref="T:System.ArgumentException">
|
|
/// <see cref="P:System.IO.FileSystemWatcher.Path" /> has not been set or is invalid.</exception>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000292 RID: 658
|
|
// (get) Token: 0x060009FD RID: 2557 RVA: 0x0001B420 File Offset: 0x00019620
|
|
// (set) Token: 0x060009FE RID: 2558 RVA: 0x0001B428 File Offset: 0x00019628
|
|
[global::System.ComponentModel.DefaultValue(false)]
|
|
[IODescription("Flag to indicate if this instance is active")]
|
|
public bool EnableRaisingEvents
|
|
{
|
|
get
|
|
{
|
|
return this.enableRaisingEvents;
|
|
}
|
|
set
|
|
{
|
|
if (value == this.enableRaisingEvents)
|
|
{
|
|
return;
|
|
}
|
|
this.enableRaisingEvents = value;
|
|
if (value)
|
|
{
|
|
this.Start();
|
|
}
|
|
else
|
|
{
|
|
this.Stop();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the filter string used to determine what files are monitored in a directory.</summary>
|
|
/// <returns>The filter string. The default is "*.*" (Watches all files.) </returns>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000293 RID: 659
|
|
// (get) Token: 0x060009FF RID: 2559 RVA: 0x0001B458 File Offset: 0x00019658
|
|
// (set) Token: 0x06000A00 RID: 2560 RVA: 0x0001B460 File Offset: 0x00019660
|
|
[IODescription("File name filter pattern")]
|
|
[global::System.ComponentModel.DefaultValue("*.*")]
|
|
[global::System.ComponentModel.RecommendedAsConfigurable(true)]
|
|
[global::System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
|
public string Filter
|
|
{
|
|
get
|
|
{
|
|
return this.filter;
|
|
}
|
|
set
|
|
{
|
|
if (value == null || value == string.Empty)
|
|
{
|
|
value = "*.*";
|
|
}
|
|
if (this.filter != value)
|
|
{
|
|
this.filter = value;
|
|
this.pattern = null;
|
|
this.mangledFilter = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets a value indicating whether subdirectories within the specified path should be monitored.</summary>
|
|
/// <returns>true if you want to monitor subdirectories; otherwise, false. The default is false.</returns>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000294 RID: 660
|
|
// (get) Token: 0x06000A01 RID: 2561 RVA: 0x0001B4B0 File Offset: 0x000196B0
|
|
// (set) Token: 0x06000A02 RID: 2562 RVA: 0x0001B4B8 File Offset: 0x000196B8
|
|
[IODescription("Flag to indicate we want to watch subdirectories")]
|
|
[global::System.ComponentModel.DefaultValue(false)]
|
|
public bool IncludeSubdirectories
|
|
{
|
|
get
|
|
{
|
|
return this.includeSubdirectories;
|
|
}
|
|
set
|
|
{
|
|
if (this.includeSubdirectories == value)
|
|
{
|
|
return;
|
|
}
|
|
this.includeSubdirectories = value;
|
|
if (value && this.enableRaisingEvents)
|
|
{
|
|
this.Stop();
|
|
this.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the size of the internal buffer.</summary>
|
|
/// <returns>The internal buffer size. The default is 8192 (8 KB).</returns>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000295 RID: 661
|
|
// (get) Token: 0x06000A03 RID: 2563 RVA: 0x0001B4EC File Offset: 0x000196EC
|
|
// (set) Token: 0x06000A04 RID: 2564 RVA: 0x0001B4F4 File Offset: 0x000196F4
|
|
[global::System.ComponentModel.DefaultValue(8192)]
|
|
[global::System.ComponentModel.Browsable(false)]
|
|
public int InternalBufferSize
|
|
{
|
|
get
|
|
{
|
|
return this.internalBufferSize;
|
|
}
|
|
set
|
|
{
|
|
if (this.internalBufferSize == value)
|
|
{
|
|
return;
|
|
}
|
|
if (value < 4196)
|
|
{
|
|
value = 4196;
|
|
}
|
|
this.internalBufferSize = value;
|
|
if (this.enableRaisingEvents)
|
|
{
|
|
this.Stop();
|
|
this.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the type of changes to watch for.</summary>
|
|
/// <returns>One of the <see cref="T:System.IO.NotifyFilters" /> values. The default is the bitwise OR combination of LastWrite, FileName, and DirectoryName.</returns>
|
|
/// <exception cref="T:System.ArgumentException">The value is not a valid bitwise OR combination of the <see cref="T:System.IO.NotifyFilters" /> values. </exception>
|
|
/// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The value that is being set is not valid.</exception>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000296 RID: 662
|
|
// (get) Token: 0x06000A05 RID: 2565 RVA: 0x0001B534 File Offset: 0x00019734
|
|
// (set) Token: 0x06000A06 RID: 2566 RVA: 0x0001B53C File Offset: 0x0001973C
|
|
[global::System.ComponentModel.DefaultValue(NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite)]
|
|
[IODescription("Flag to indicate which change event we want to monitor")]
|
|
public NotifyFilters NotifyFilter
|
|
{
|
|
get
|
|
{
|
|
return this.notifyFilter;
|
|
}
|
|
set
|
|
{
|
|
if (this.notifyFilter == value)
|
|
{
|
|
return;
|
|
}
|
|
this.notifyFilter = value;
|
|
if (this.enableRaisingEvents)
|
|
{
|
|
this.Stop();
|
|
this.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the path of the directory to watch.</summary>
|
|
/// <returns>The path to monitor. The default is an empty string ("").</returns>
|
|
/// <exception cref="T:System.ArgumentException">The specified path does not exist or could not be found.-or- The specified path contains wildcard characters.-or- The specified path contains invalid path characters.</exception>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000297 RID: 663
|
|
// (get) Token: 0x06000A07 RID: 2567 RVA: 0x0001B56C File Offset: 0x0001976C
|
|
// (set) Token: 0x06000A08 RID: 2568 RVA: 0x0001B574 File Offset: 0x00019774
|
|
[global::System.ComponentModel.RecommendedAsConfigurable(true)]
|
|
[global::System.ComponentModel.DefaultValue("")]
|
|
[IODescription("The directory to monitor")]
|
|
[global::System.ComponentModel.Editor("System.Diagnostics.Design.FSWPathEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
|
[global::System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
|
public string Path
|
|
{
|
|
get
|
|
{
|
|
return this.path;
|
|
}
|
|
set
|
|
{
|
|
if (this.path == value)
|
|
{
|
|
return;
|
|
}
|
|
bool flag = false;
|
|
Exception ex = null;
|
|
try
|
|
{
|
|
flag = Directory.Exists(value);
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
ex = ex2;
|
|
}
|
|
if (ex != null)
|
|
{
|
|
throw new ArgumentException("Invalid directory name", "value", ex);
|
|
}
|
|
if (!flag)
|
|
{
|
|
throw new ArgumentException("Directory does not exists", "value");
|
|
}
|
|
this.path = value;
|
|
this.fullpath = null;
|
|
if (this.enableRaisingEvents)
|
|
{
|
|
this.Stop();
|
|
this.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets an <see cref="T:System.ComponentModel.ISite" /> for the <see cref="T:System.IO.FileSystemWatcher" />.</summary>
|
|
/// <returns>An <see cref="T:System.ComponentModel.ISite" /> for the <see cref="T:System.IO.FileSystemWatcher" />.</returns>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000298 RID: 664
|
|
// (get) Token: 0x06000A09 RID: 2569 RVA: 0x0001B61C File Offset: 0x0001981C
|
|
// (set) Token: 0x06000A0A RID: 2570 RVA: 0x0001B624 File Offset: 0x00019824
|
|
[global::System.ComponentModel.Browsable(false)]
|
|
public override global::System.ComponentModel.ISite Site
|
|
{
|
|
get
|
|
{
|
|
return base.Site;
|
|
}
|
|
set
|
|
{
|
|
base.Site = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the object used to marshal the event handler calls issued as a result of a directory change.</summary>
|
|
/// <returns>The <see cref="T:System.ComponentModel.ISynchronizeInvoke" /> that represents the object used to marshal the event handler calls issued as a result of a directory change. The default is null.</returns>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x17000299 RID: 665
|
|
// (get) Token: 0x06000A0B RID: 2571 RVA: 0x0001B630 File Offset: 0x00019830
|
|
// (set) Token: 0x06000A0C RID: 2572 RVA: 0x0001B638 File Offset: 0x00019838
|
|
[global::System.ComponentModel.Browsable(false)]
|
|
[IODescription("The object used to marshal the event handler calls resulting from a directory change")]
|
|
[global::System.ComponentModel.DefaultValue(null)]
|
|
public global::System.ComponentModel.ISynchronizeInvoke SynchronizingObject
|
|
{
|
|
get
|
|
{
|
|
return this.synchronizingObject;
|
|
}
|
|
set
|
|
{
|
|
this.synchronizingObject = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Begins the initialization of a <see cref="T:System.IO.FileSystemWatcher" /> used on a form or used by another component. The initialization occurs at run time.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x06000A0D RID: 2573 RVA: 0x0001B644 File Offset: 0x00019844
|
|
public void BeginInit()
|
|
{
|
|
}
|
|
|
|
/// <summary>Releases the unmanaged resources used by the <see cref="T:System.IO.FileSystemWatcher" /> and optionally releases the managed resources.</summary>
|
|
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
|
|
// Token: 0x06000A0E RID: 2574 RVA: 0x0001B648 File Offset: 0x00019848
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (!this.disposed)
|
|
{
|
|
this.disposed = true;
|
|
this.Stop();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
// Token: 0x06000A0F RID: 2575 RVA: 0x0001B66C File Offset: 0x0001986C
|
|
~FileSystemWatcher()
|
|
{
|
|
this.disposed = true;
|
|
this.Stop();
|
|
}
|
|
|
|
/// <summary>Ends the initialization of a <see cref="T:System.IO.FileSystemWatcher" /> used on a form or used by another component. The initialization occurs at run time.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x06000A10 RID: 2576 RVA: 0x0001B6B0 File Offset: 0x000198B0
|
|
public void EndInit()
|
|
{
|
|
}
|
|
|
|
// Token: 0x06000A11 RID: 2577 RVA: 0x0001B6B4 File Offset: 0x000198B4
|
|
private void RaiseEvent(Delegate ev, EventArgs arg, FileSystemWatcher.EventType evtype)
|
|
{
|
|
if (ev == null)
|
|
{
|
|
return;
|
|
}
|
|
if (this.synchronizingObject == null)
|
|
{
|
|
switch (evtype)
|
|
{
|
|
case FileSystemWatcher.EventType.FileSystemEvent:
|
|
((FileSystemEventHandler)ev).BeginInvoke(this, (FileSystemEventArgs)arg, null, null);
|
|
break;
|
|
case FileSystemWatcher.EventType.ErrorEvent:
|
|
((ErrorEventHandler)ev).BeginInvoke(this, (ErrorEventArgs)arg, null, null);
|
|
break;
|
|
case FileSystemWatcher.EventType.RenameEvent:
|
|
((RenamedEventHandler)ev).BeginInvoke(this, (RenamedEventArgs)arg, null, null);
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
this.synchronizingObject.BeginInvoke(ev, new object[] { this, arg });
|
|
}
|
|
|
|
/// <summary>Raises the <see cref="E:System.IO.FileSystemWatcher.Changed" /> event.</summary>
|
|
/// <param name="e">A <see cref="T:System.IO.FileSystemEventArgs" /> that contains the event data. </param>
|
|
// Token: 0x06000A12 RID: 2578 RVA: 0x0001B758 File Offset: 0x00019958
|
|
protected void OnChanged(FileSystemEventArgs e)
|
|
{
|
|
this.RaiseEvent(this.Changed, e, FileSystemWatcher.EventType.FileSystemEvent);
|
|
}
|
|
|
|
/// <summary>Raises the <see cref="E:System.IO.FileSystemWatcher.Created" /> event.</summary>
|
|
/// <param name="e">A <see cref="T:System.IO.FileSystemEventArgs" /> that contains the event data. </param>
|
|
// Token: 0x06000A13 RID: 2579 RVA: 0x0001B768 File Offset: 0x00019968
|
|
protected void OnCreated(FileSystemEventArgs e)
|
|
{
|
|
this.RaiseEvent(this.Created, e, FileSystemWatcher.EventType.FileSystemEvent);
|
|
}
|
|
|
|
/// <summary>Raises the <see cref="E:System.IO.FileSystemWatcher.Deleted" /> event.</summary>
|
|
/// <param name="e">A <see cref="T:System.IO.FileSystemEventArgs" /> that contains the event data. </param>
|
|
// Token: 0x06000A14 RID: 2580 RVA: 0x0001B778 File Offset: 0x00019978
|
|
protected void OnDeleted(FileSystemEventArgs e)
|
|
{
|
|
this.RaiseEvent(this.Deleted, e, FileSystemWatcher.EventType.FileSystemEvent);
|
|
}
|
|
|
|
/// <summary>Raises the <see cref="E:System.IO.FileSystemWatcher.Error" /> event.</summary>
|
|
/// <param name="e">An <see cref="T:System.IO.ErrorEventArgs" /> that contains the event data. </param>
|
|
// Token: 0x06000A15 RID: 2581 RVA: 0x0001B788 File Offset: 0x00019988
|
|
protected void OnError(ErrorEventArgs e)
|
|
{
|
|
this.RaiseEvent(this.Error, e, FileSystemWatcher.EventType.ErrorEvent);
|
|
}
|
|
|
|
/// <summary>Raises the <see cref="E:System.IO.FileSystemWatcher.Renamed" /> event.</summary>
|
|
/// <param name="e">A <see cref="T:System.IO.RenamedEventArgs" /> that contains the event data. </param>
|
|
// Token: 0x06000A16 RID: 2582 RVA: 0x0001B798 File Offset: 0x00019998
|
|
protected void OnRenamed(RenamedEventArgs e)
|
|
{
|
|
this.RaiseEvent(this.Renamed, e, FileSystemWatcher.EventType.RenameEvent);
|
|
}
|
|
|
|
/// <summary>A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor.</summary>
|
|
/// <returns>A <see cref="T:System.IO.WaitForChangedResult" /> that contains specific information on the change that occurred.</returns>
|
|
/// <param name="changeType">The <see cref="T:System.IO.WatcherChangeTypes" /> to watch for. </param>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x06000A17 RID: 2583 RVA: 0x0001B7A8 File Offset: 0x000199A8
|
|
public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType)
|
|
{
|
|
return this.WaitForChanged(changeType, -1);
|
|
}
|
|
|
|
/// <summary>A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor and the time (in milliseconds) to wait before timing out.</summary>
|
|
/// <returns>A <see cref="T:System.IO.WaitForChangedResult" /> that contains specific information on the change that occurred.</returns>
|
|
/// <param name="changeType">The <see cref="T:System.IO.WatcherChangeTypes" /> to watch for. </param>
|
|
/// <param name="timeout">The time (in milliseconds) to wait before timing out. </param>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x06000A18 RID: 2584 RVA: 0x0001B7B4 File Offset: 0x000199B4
|
|
public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)
|
|
{
|
|
WaitForChangedResult waitForChangedResult = default(WaitForChangedResult);
|
|
bool flag = this.EnableRaisingEvents;
|
|
if (!flag)
|
|
{
|
|
this.EnableRaisingEvents = true;
|
|
}
|
|
bool flag2;
|
|
lock (this)
|
|
{
|
|
this.waiting = true;
|
|
flag2 = Monitor.Wait(this, timeout);
|
|
if (flag2)
|
|
{
|
|
waitForChangedResult = this.lastData;
|
|
}
|
|
}
|
|
this.EnableRaisingEvents = flag;
|
|
if (!flag2)
|
|
{
|
|
waitForChangedResult.TimedOut = true;
|
|
}
|
|
return waitForChangedResult;
|
|
}
|
|
|
|
// Token: 0x06000A19 RID: 2585 RVA: 0x0001B840 File Offset: 0x00019A40
|
|
internal void DispatchEvents(FileAction act, string filename, ref RenamedEventArgs renamed)
|
|
{
|
|
if (this.waiting)
|
|
{
|
|
this.lastData = default(WaitForChangedResult);
|
|
}
|
|
switch (act)
|
|
{
|
|
case FileAction.Added:
|
|
this.lastData.Name = filename;
|
|
this.lastData.ChangeType = WatcherChangeTypes.Created;
|
|
this.OnCreated(new FileSystemEventArgs(WatcherChangeTypes.Created, this.path, filename));
|
|
break;
|
|
case FileAction.Removed:
|
|
this.lastData.Name = filename;
|
|
this.lastData.ChangeType = WatcherChangeTypes.Deleted;
|
|
this.OnDeleted(new FileSystemEventArgs(WatcherChangeTypes.Deleted, this.path, filename));
|
|
break;
|
|
case FileAction.Modified:
|
|
this.lastData.Name = filename;
|
|
this.lastData.ChangeType = WatcherChangeTypes.Changed;
|
|
this.OnChanged(new FileSystemEventArgs(WatcherChangeTypes.Changed, this.path, filename));
|
|
break;
|
|
case FileAction.RenamedOldName:
|
|
if (renamed != null)
|
|
{
|
|
this.OnRenamed(renamed);
|
|
}
|
|
this.lastData.OldName = filename;
|
|
this.lastData.ChangeType = WatcherChangeTypes.Renamed;
|
|
renamed = new RenamedEventArgs(WatcherChangeTypes.Renamed, this.path, filename, string.Empty);
|
|
break;
|
|
case FileAction.RenamedNewName:
|
|
this.lastData.Name = filename;
|
|
this.lastData.ChangeType = WatcherChangeTypes.Renamed;
|
|
if (renamed == null)
|
|
{
|
|
renamed = new RenamedEventArgs(WatcherChangeTypes.Renamed, this.path, string.Empty, filename);
|
|
}
|
|
this.OnRenamed(renamed);
|
|
renamed = null;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000A1A RID: 2586 RVA: 0x0001B9A4 File Offset: 0x00019BA4
|
|
private void Start()
|
|
{
|
|
FileSystemWatcher.watcher.StartDispatching(this);
|
|
}
|
|
|
|
// Token: 0x06000A1B RID: 2587 RVA: 0x0001B9B4 File Offset: 0x00019BB4
|
|
private void Stop()
|
|
{
|
|
FileSystemWatcher.watcher.StopDispatching(this);
|
|
}
|
|
|
|
// Token: 0x06000A1C RID: 2588
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern int InternalSupportsFSW();
|
|
|
|
// Token: 0x04000362 RID: 866
|
|
private bool enableRaisingEvents;
|
|
|
|
// Token: 0x04000363 RID: 867
|
|
private string filter;
|
|
|
|
// Token: 0x04000364 RID: 868
|
|
private bool includeSubdirectories;
|
|
|
|
// Token: 0x04000365 RID: 869
|
|
private int internalBufferSize;
|
|
|
|
// Token: 0x04000366 RID: 870
|
|
private NotifyFilters notifyFilter;
|
|
|
|
// Token: 0x04000367 RID: 871
|
|
private string path;
|
|
|
|
// Token: 0x04000368 RID: 872
|
|
private string fullpath;
|
|
|
|
// Token: 0x04000369 RID: 873
|
|
private global::System.ComponentModel.ISynchronizeInvoke synchronizingObject;
|
|
|
|
// Token: 0x0400036A RID: 874
|
|
private WaitForChangedResult lastData;
|
|
|
|
// Token: 0x0400036B RID: 875
|
|
private bool waiting;
|
|
|
|
// Token: 0x0400036C RID: 876
|
|
private SearchPattern2 pattern;
|
|
|
|
// Token: 0x0400036D RID: 877
|
|
private bool disposed;
|
|
|
|
// Token: 0x0400036E RID: 878
|
|
private string mangledFilter;
|
|
|
|
// Token: 0x0400036F RID: 879
|
|
private static IFileWatcher watcher;
|
|
|
|
// Token: 0x04000370 RID: 880
|
|
private static object lockobj = new object();
|
|
|
|
// Token: 0x02000117 RID: 279
|
|
private enum EventType
|
|
{
|
|
// Token: 0x04000377 RID: 887
|
|
FileSystemEvent,
|
|
// Token: 0x04000378 RID: 888
|
|
ErrorEvent,
|
|
// Token: 0x04000379 RID: 889
|
|
RenameEvent
|
|
}
|
|
}
|
|
}
|