FileWatcher.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // FileWatcher.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.IO
  18. {
  19. /// <summary>
  20. /// Watches a directory and its subdirectories for files being modified.
  21. /// </summary>
  22. public unsafe partial class FileWatcher : UrhoObject
  23. {
  24. public FileWatcher (IntPtr handle) : base (handle)
  25. {
  26. }
  27. protected FileWatcher (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  28. {
  29. }
  30. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  31. internal static extern int FileWatcher_GetType (IntPtr handle);
  32. private StringHash UrhoGetType ()
  33. {
  34. Runtime.ValidateRefCounted (this);
  35. return new StringHash (FileWatcher_GetType (handle));
  36. }
  37. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  38. internal static extern IntPtr FileWatcher_GetTypeName (IntPtr handle);
  39. private string GetTypeName ()
  40. {
  41. Runtime.ValidateRefCounted (this);
  42. return Marshal.PtrToStringAnsi (FileWatcher_GetTypeName (handle));
  43. }
  44. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  45. internal static extern int FileWatcher_GetTypeStatic ();
  46. private static StringHash GetTypeStatic ()
  47. {
  48. Runtime.Validate (typeof(FileWatcher));
  49. return new StringHash (FileWatcher_GetTypeStatic ());
  50. }
  51. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  52. internal static extern IntPtr FileWatcher_GetTypeNameStatic ();
  53. private static string GetTypeNameStatic ()
  54. {
  55. Runtime.Validate (typeof(FileWatcher));
  56. return Marshal.PtrToStringAnsi (FileWatcher_GetTypeNameStatic ());
  57. }
  58. public FileWatcher () : this (Application.CurrentContext)
  59. {
  60. }
  61. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  62. internal static extern IntPtr FileWatcher_FileWatcher (IntPtr context);
  63. public FileWatcher (Context context) : base (UrhoObjectFlag.Empty)
  64. {
  65. Runtime.Validate (typeof(FileWatcher));
  66. handle = FileWatcher_FileWatcher ((object)context == null ? IntPtr.Zero : context.Handle);
  67. Runtime.RegisterObject (this);
  68. }
  69. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  70. internal static extern void FileWatcher_ThreadFunction (IntPtr handle);
  71. /// <summary>
  72. /// Directory watching loop.
  73. /// </summary>
  74. public void ThreadFunction ()
  75. {
  76. Runtime.ValidateRefCounted (this);
  77. FileWatcher_ThreadFunction (handle);
  78. }
  79. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  80. internal static extern bool FileWatcher_StartWatching (IntPtr handle, string pathName, bool watchSubDirs);
  81. /// <summary>
  82. /// Start watching a directory. Return true if successful.
  83. /// </summary>
  84. public bool StartWatching (string pathName, bool watchSubDirs)
  85. {
  86. Runtime.ValidateRefCounted (this);
  87. return FileWatcher_StartWatching (handle, pathName, watchSubDirs);
  88. }
  89. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  90. internal static extern void FileWatcher_StopWatching (IntPtr handle);
  91. /// <summary>
  92. /// Stop watching the directory.
  93. /// </summary>
  94. public void StopWatching ()
  95. {
  96. Runtime.ValidateRefCounted (this);
  97. FileWatcher_StopWatching (handle);
  98. }
  99. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  100. internal static extern void FileWatcher_SetDelay (IntPtr handle, float interval);
  101. /// <summary>
  102. /// Set the delay in seconds before file changes are notified. This (hopefully) avoids notifying when a file save is still in progress. Default 1 second.
  103. /// </summary>
  104. private void SetDelay (float interval)
  105. {
  106. Runtime.ValidateRefCounted (this);
  107. FileWatcher_SetDelay (handle, interval);
  108. }
  109. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  110. internal static extern void FileWatcher_AddChange (IntPtr handle, string fileName);
  111. /// <summary>
  112. /// Add a file change into the changes queue.
  113. /// </summary>
  114. public void AddChange (string fileName)
  115. {
  116. Runtime.ValidateRefCounted (this);
  117. FileWatcher_AddChange (handle, fileName);
  118. }
  119. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  120. internal static extern IntPtr FileWatcher_GetPath (IntPtr handle);
  121. /// <summary>
  122. /// Return the path being watched, or empty if not watching.
  123. /// </summary>
  124. private string GetPath ()
  125. {
  126. Runtime.ValidateRefCounted (this);
  127. return Marshal.PtrToStringAnsi (FileWatcher_GetPath (handle));
  128. }
  129. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  130. internal static extern float FileWatcher_GetDelay (IntPtr handle);
  131. /// <summary>
  132. /// Return the delay in seconds for notifying file changes.
  133. /// </summary>
  134. private float GetDelay ()
  135. {
  136. Runtime.ValidateRefCounted (this);
  137. return FileWatcher_GetDelay (handle);
  138. }
  139. public override StringHash Type {
  140. get {
  141. return UrhoGetType ();
  142. }
  143. }
  144. public override string TypeName {
  145. get {
  146. return GetTypeName ();
  147. }
  148. }
  149. public static StringHash TypeStatic {
  150. get {
  151. return GetTypeStatic ();
  152. }
  153. }
  154. public static string TypeNameStatic {
  155. get {
  156. return GetTypeNameStatic ();
  157. }
  158. }
  159. /// <summary>
  160. /// Return the delay in seconds for notifying file changes.
  161. /// Or
  162. /// Set the delay in seconds before file changes are notified. This (hopefully) avoids notifying when a file save is still in progress. Default 1 second.
  163. /// </summary>
  164. public float Delay {
  165. get {
  166. return GetDelay ();
  167. }
  168. set {
  169. SetDelay (value);
  170. }
  171. }
  172. /// <summary>
  173. /// Return the path being watched, or empty if not watching.
  174. /// </summary>
  175. public string Path {
  176. get {
  177. return GetPath ();
  178. }
  179. }
  180. }
  181. }