FolderMonitor.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BansheeEngine;
  8. namespace BansheeEditor
  9. {
  10. public class FolderMonitor : ScriptObject
  11. {
  12. public Action<string> OnModified;
  13. public Action<string> OnAdded;
  14. public Action<string> OnRemoved;
  15. public Action<string, string> OnRenamed;
  16. public FolderMonitor(string folderToMonitor)
  17. {
  18. Internal_CreateInstance(this, folderToMonitor);
  19. }
  20. public void Destroy()
  21. {
  22. Internal_Destroy(mCachedPtr);
  23. }
  24. private void Internal_DoOnModified(string path)
  25. {
  26. if (OnModified != null)
  27. OnModified(path);
  28. }
  29. private void Internal_DoOnAdded(string path)
  30. {
  31. if (OnAdded != null)
  32. OnAdded(path);
  33. }
  34. private void Internal_DoOnRemoved(string path)
  35. {
  36. if (OnRemoved != null)
  37. OnRemoved(path);
  38. }
  39. private void Internal_DoOnRenamed(string from, string to)
  40. {
  41. if (OnRenamed != null)
  42. OnRenamed(from, to);
  43. }
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern void Internal_CreateInstance(FolderMonitor instance, string folder);
  46. [MethodImpl(MethodImplOptions.InternalCall)]
  47. private static extern void Internal_Destroy(IntPtr thisPtr);
  48. }
  49. }