You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
2
2
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3
-
usingSystem;
4
-
usingSystem.Collections.Generic;
5
-
usingSystem.Threading;
3
+
namespaceStride.Core.IO;
6
4
7
-
namespaceStride.Core.IO
5
+
/// <summary>
6
+
/// Track file system events from several directories.
7
+
/// </summary>
8
+
publicpartialclassDirectoryWatcher:IDisposable
8
9
{
10
+
privateconstintSleepBetweenWatcherCheck=200;
11
+
privateThread?watcherCheckThread;
12
+
privateboolexitThread;
13
+
14
+
/// <summary>
15
+
/// Occurs when a file/directory change occurred.
16
+
/// </summary>
17
+
publiceventEventHandler<FileEvent>?Modified;
18
+
9
19
/// <summary>
10
-
/// Track file system events from several directories.
20
+
/// Initializes a new instance of the <see cref="DirectoryWatcher"/> class.
11
21
/// </summary>
12
-
publicpartialclassDirectoryWatcher:IDisposable
22
+
/// <param name="fileFilter">The file filter By default null default to *.*</param>
23
+
publicDirectoryWatcher(string?fileFilter=null)
13
24
{
14
-
privateconstintSleepBetweenWatcherCheck=200;
15
-
privateThreadwatcherCheckThread;
16
-
privateboolexitThread;
17
-
18
-
/// <summary>
19
-
/// Occurs when a file/directory change occurred.
20
-
/// </summary>
21
-
publiceventEventHandler<FileEvent>Modified;
22
-
23
-
/// <summary>
24
-
/// Initializes a new instance of the <see cref="DirectoryWatcher"/> class.
25
-
/// </summary>
26
-
/// <param name="fileFilter">The file filter By default null default to *.*</param>
27
-
publicDirectoryWatcher(stringfileFilter=null)
28
-
{
29
-
FileFilter=fileFilter??"*.*";
30
-
InitializeInternal();
31
-
}
25
+
FileFilter=fileFilter??"*.*";
26
+
InitializeInternal();
27
+
}
28
+
29
+
/// <summary>
30
+
/// Gets the file filter used by this instance.
31
+
/// </summary>
32
+
/// <value>The file filter.</value>
33
+
publicstringFileFilter{get;privateset;}
32
34
33
-
/// <summary>
34
-
/// Gets the file filter used by this instance.
35
-
/// </summary>
36
-
/// <value>The file filter.</value>
37
-
publicstringFileFilter{get;privateset;}
35
+
/// <summary>
36
+
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
37
+
/// </summary>
38
+
publicvoidDispose()
39
+
{
40
+
Dispose(true);
41
+
GC.SuppressFinalize(this);
42
+
}
38
43
39
-
/// <summary>
40
-
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
41
-
/// </summary>
42
-
publicvirtualvoidDispose()
44
+
protectedvirtualvoidDispose(booldisposing)
45
+
{
46
+
if(disposing)
43
47
{
44
48
exitThread=true;
45
49
if(watcherCheckThread!=null)
@@ -49,72 +53,72 @@ public virtual void Dispose()
49
53
}
50
54
DisposeInternal();
51
55
}
56
+
}
52
57
53
-
/// <summary>
54
-
/// Gets a list of current directories being tracked.
55
-
/// </summary>
56
-
/// <returns>A list of current directories being tracked</returns>
57
-
publicList<string>GetTrackedDirectories()
58
-
{
59
-
returnGetTrackedDirectoriesInternal();
60
-
}
58
+
/// <summary>
59
+
/// Gets a list of current directories being tracked.
60
+
/// </summary>
61
+
/// <returns>A list of current directories being tracked</returns>
62
+
publicList<string>GetTrackedDirectories()
63
+
{
64
+
returnGetTrackedDirectoriesInternal();
65
+
}
61
66
62
-
/// <summary>
63
-
/// Tracks the specified path.
64
-
/// </summary>
65
-
/// <param name="path">The path.</param>
66
-
/// <remarks>
67
-
/// If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.
68
-
/// </remarks>
69
-
publicvoidTrack(stringpath)
70
-
{
71
-
TrackInternal(path);
72
-
}
67
+
/// <summary>
68
+
/// Tracks the specified path.
69
+
/// </summary>
70
+
/// <param name="path">The path.</param>
71
+
/// <remarks>
72
+
/// If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.
73
+
/// </remarks>
74
+
publicvoidTrack(stringpath)
75
+
{
76
+
TrackInternal(path);
77
+
}
73
78
74
-
/// <summary>
75
-
/// UnTracks the specified path.
76
-
/// </summary>
77
-
/// <remarks>
78
-
/// If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.
79
-
/// </remarks>
80
-
publicvoidUnTrack(stringpath)
81
-
{
82
-
UnTrackInternal(path);
83
-
}
79
+
/// <summary>
80
+
/// UnTracks the specified path.
81
+
/// </summary>
82
+
/// <remarks>
83
+
/// If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.
0 commit comments