FileWatcher.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. unsafe partial void OnFileWatcherCreated ();
  25. [Preserve]
  26. public FileWatcher (IntPtr handle) : base (handle)
  27. {
  28. OnFileWatcherCreated ();
  29. }
  30. [Preserve]
  31. protected FileWatcher (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnFileWatcherCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int FileWatcher_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (FileWatcher_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr FileWatcher_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (FileWatcher_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int FileWatcher_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(FileWatcher));
  54. return new StringHash (FileWatcher_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr FileWatcher_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(FileWatcher));
  61. return Marshal.PtrToStringAnsi (FileWatcher_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public FileWatcher () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr FileWatcher_FileWatcher (IntPtr context);
  69. [Preserve]
  70. public FileWatcher (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(FileWatcher));
  73. handle = FileWatcher_FileWatcher ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnFileWatcherCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void FileWatcher_ThreadFunction (IntPtr handle);
  79. /// <summary>
  80. /// Directory watching loop.
  81. /// </summary>
  82. public void ThreadFunction ()
  83. {
  84. Runtime.ValidateRefCounted (this);
  85. FileWatcher_ThreadFunction (handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool FileWatcher_StartWatching (IntPtr handle, string pathName, bool watchSubDirs);
  89. /// <summary>
  90. /// Start watching a directory. Return true if successful.
  91. /// </summary>
  92. public bool StartWatching (string pathName, bool watchSubDirs)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return FileWatcher_StartWatching (handle, pathName, watchSubDirs);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern void FileWatcher_StopWatching (IntPtr handle);
  99. /// <summary>
  100. /// Stop watching the directory.
  101. /// </summary>
  102. public void StopWatching ()
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. FileWatcher_StopWatching (handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern void FileWatcher_SetDelay (IntPtr handle, float interval);
  109. /// <summary>
  110. /// 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.
  111. /// </summary>
  112. private void SetDelay (float interval)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. FileWatcher_SetDelay (handle, interval);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern void FileWatcher_AddChange (IntPtr handle, string fileName);
  119. /// <summary>
  120. /// Add a file change into the changes queue.
  121. /// </summary>
  122. public void AddChange (string fileName)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. FileWatcher_AddChange (handle, fileName);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern IntPtr FileWatcher_GetPath (IntPtr handle);
  129. /// <summary>
  130. /// Return the path being watched, or empty if not watching.
  131. /// </summary>
  132. private string GetPath ()
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. return Marshal.PtrToStringAnsi (FileWatcher_GetPath (handle));
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern float FileWatcher_GetDelay (IntPtr handle);
  139. /// <summary>
  140. /// Return the delay in seconds for notifying file changes.
  141. /// </summary>
  142. private float GetDelay ()
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. return FileWatcher_GetDelay (handle);
  146. }
  147. public override StringHash Type {
  148. get {
  149. return UrhoGetType ();
  150. }
  151. }
  152. public override string TypeName {
  153. get {
  154. return GetTypeName ();
  155. }
  156. }
  157. [Preserve]
  158. public static StringHash TypeStatic {
  159. get {
  160. return GetTypeStatic ();
  161. }
  162. }
  163. public static string TypeNameStatic {
  164. get {
  165. return GetTypeNameStatic ();
  166. }
  167. }
  168. /// <summary>
  169. /// Return the delay in seconds for notifying file changes.
  170. /// Or
  171. /// 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.
  172. /// </summary>
  173. public float Delay {
  174. get {
  175. return GetDelay ();
  176. }
  177. set {
  178. SetDelay (value);
  179. }
  180. }
  181. /// <summary>
  182. /// Return the path being watched, or empty if not watching.
  183. /// </summary>
  184. public string Path {
  185. get {
  186. return GetPath ();
  187. }
  188. }
  189. }
  190. }