FileSystem.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // FileSystem.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. /// Subsystem for file and directory operations and access control.
  21. /// </summary>
  22. public unsafe partial class FileSystem : UrhoObject
  23. {
  24. public FileSystem (IntPtr handle) : base (handle)
  25. {
  26. }
  27. protected FileSystem (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  28. {
  29. }
  30. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  31. internal static extern int FileSystem_GetType (IntPtr handle);
  32. private StringHash UrhoGetType ()
  33. {
  34. Runtime.ValidateRefCounted (this);
  35. return new StringHash (FileSystem_GetType (handle));
  36. }
  37. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  38. internal static extern IntPtr FileSystem_GetTypeName (IntPtr handle);
  39. private string GetTypeName ()
  40. {
  41. Runtime.ValidateRefCounted (this);
  42. return Marshal.PtrToStringAnsi (FileSystem_GetTypeName (handle));
  43. }
  44. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  45. internal static extern int FileSystem_GetTypeStatic ();
  46. private static StringHash GetTypeStatic ()
  47. {
  48. Runtime.Validate (typeof(FileSystem));
  49. return new StringHash (FileSystem_GetTypeStatic ());
  50. }
  51. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  52. internal static extern IntPtr FileSystem_GetTypeNameStatic ();
  53. private static string GetTypeNameStatic ()
  54. {
  55. Runtime.Validate (typeof(FileSystem));
  56. return Marshal.PtrToStringAnsi (FileSystem_GetTypeNameStatic ());
  57. }
  58. public FileSystem () : this (Application.CurrentContext)
  59. {
  60. }
  61. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  62. internal static extern IntPtr FileSystem_FileSystem (IntPtr context);
  63. public FileSystem (Context context) : base (UrhoObjectFlag.Empty)
  64. {
  65. Runtime.Validate (typeof(FileSystem));
  66. handle = FileSystem_FileSystem ((object)context == null ? IntPtr.Zero : context.Handle);
  67. Runtime.RegisterObject (this);
  68. }
  69. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  70. internal static extern bool FileSystem_SetCurrentDir (IntPtr handle, string pathName);
  71. /// <summary>
  72. /// Set the current working directory.
  73. /// </summary>
  74. public bool SetCurrentDir (string pathName)
  75. {
  76. Runtime.ValidateRefCounted (this);
  77. return FileSystem_SetCurrentDir (handle, pathName);
  78. }
  79. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  80. internal static extern bool FileSystem_CreateDir (IntPtr handle, string pathName);
  81. /// <summary>
  82. /// Create a directory.
  83. /// </summary>
  84. public bool CreateDir (string pathName)
  85. {
  86. Runtime.ValidateRefCounted (this);
  87. return FileSystem_CreateDir (handle, pathName);
  88. }
  89. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  90. internal static extern void FileSystem_SetExecuteConsoleCommands (IntPtr handle, bool enable);
  91. /// <summary>
  92. /// Set whether to execute engine console commands as OS-specific system command.
  93. /// </summary>
  94. private void SetExecuteConsoleCommands (bool enable)
  95. {
  96. Runtime.ValidateRefCounted (this);
  97. FileSystem_SetExecuteConsoleCommands (handle, enable);
  98. }
  99. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  100. internal static extern int FileSystem_SystemCommand (IntPtr handle, string commandLine, bool redirectStdOutToLog);
  101. /// <summary>
  102. /// Run a program using the command interpreter, block until it exits and return the exit code. Will fail if any allowed paths are defined.
  103. /// </summary>
  104. public int SystemCommand (string commandLine, bool redirectStdOutToLog)
  105. {
  106. Runtime.ValidateRefCounted (this);
  107. return FileSystem_SystemCommand (handle, commandLine, redirectStdOutToLog);
  108. }
  109. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  110. internal static extern uint FileSystem_SystemCommandAsync (IntPtr handle, string commandLine);
  111. /// <summary>
  112. /// Run a program using the command interpreter asynchronously. Return a request ID or M_MAX_UNSIGNED if failed. The exit code will be posted together with the request ID in an AsyncExecFinished event. Will fail if any allowed paths are defined.
  113. /// </summary>
  114. public uint SystemCommandAsync (string commandLine)
  115. {
  116. Runtime.ValidateRefCounted (this);
  117. return FileSystem_SystemCommandAsync (handle, commandLine);
  118. }
  119. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  120. internal static extern bool FileSystem_SystemOpen (IntPtr handle, string fileName, string mode);
  121. /// <summary>
  122. /// Open a file in an external program, with mode such as "edit" optionally specified. Will fail if any allowed paths are defined.
  123. /// </summary>
  124. public bool SystemOpen (string fileName, string mode)
  125. {
  126. Runtime.ValidateRefCounted (this);
  127. return FileSystem_SystemOpen (handle, fileName, mode);
  128. }
  129. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  130. internal static extern bool FileSystem_Copy (IntPtr handle, string srcFileName, string destFileName);
  131. /// <summary>
  132. /// Copy a file. Return true if successful.
  133. /// </summary>
  134. public bool Copy (string srcFileName, string destFileName)
  135. {
  136. Runtime.ValidateRefCounted (this);
  137. return FileSystem_Copy (handle, srcFileName, destFileName);
  138. }
  139. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  140. internal static extern bool FileSystem_Rename (IntPtr handle, string srcFileName, string destFileName);
  141. /// <summary>
  142. /// Rename a file. Return true if successful.
  143. /// </summary>
  144. public bool Rename (string srcFileName, string destFileName)
  145. {
  146. Runtime.ValidateRefCounted (this);
  147. return FileSystem_Rename (handle, srcFileName, destFileName);
  148. }
  149. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  150. internal static extern bool FileSystem_Delete (IntPtr handle, string fileName);
  151. /// <summary>
  152. /// Delete a file. Return true if successful.
  153. /// </summary>
  154. public bool Delete (string fileName)
  155. {
  156. Runtime.ValidateRefCounted (this);
  157. return FileSystem_Delete (handle, fileName);
  158. }
  159. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  160. internal static extern void FileSystem_RegisterPath (IntPtr handle, string pathName);
  161. /// <summary>
  162. /// Register a path as allowed to access. If no paths are registered, all are allowed. Registering allowed paths is considered securing the Urho3D execution environment: running programs and opening files externally through the system will fail afterward.
  163. /// </summary>
  164. public void RegisterPath (string pathName)
  165. {
  166. Runtime.ValidateRefCounted (this);
  167. FileSystem_RegisterPath (handle, pathName);
  168. }
  169. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  170. internal static extern bool FileSystem_SetLastModifiedTime (IntPtr handle, string fileName, uint newTime);
  171. /// <summary>
  172. /// Set a file's last modified time as seconds since 1.1.1970. Return true on success.
  173. /// </summary>
  174. public bool SetLastModifiedTime (string fileName, uint newTime)
  175. {
  176. Runtime.ValidateRefCounted (this);
  177. return FileSystem_SetLastModifiedTime (handle, fileName, newTime);
  178. }
  179. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  180. internal static extern IntPtr FileSystem_GetCurrentDir (IntPtr handle);
  181. /// <summary>
  182. /// Return the absolute current working directory.
  183. /// </summary>
  184. private string GetCurrentDir ()
  185. {
  186. Runtime.ValidateRefCounted (this);
  187. return Marshal.PtrToStringAnsi (FileSystem_GetCurrentDir (handle));
  188. }
  189. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  190. internal static extern bool FileSystem_GetExecuteConsoleCommands (IntPtr handle);
  191. /// <summary>
  192. /// Return whether is executing engine console commands as OS-specific system command.
  193. /// </summary>
  194. private bool GetExecuteConsoleCommands ()
  195. {
  196. Runtime.ValidateRefCounted (this);
  197. return FileSystem_GetExecuteConsoleCommands (handle);
  198. }
  199. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  200. internal static extern bool FileSystem_HasRegisteredPaths (IntPtr handle);
  201. /// <summary>
  202. /// Return whether paths have been registered.
  203. /// </summary>
  204. public bool HasRegisteredPaths ()
  205. {
  206. Runtime.ValidateRefCounted (this);
  207. return FileSystem_HasRegisteredPaths (handle);
  208. }
  209. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  210. internal static extern bool FileSystem_CheckAccess (IntPtr handle, string pathName);
  211. /// <summary>
  212. /// Check if a path is allowed to be accessed. If no paths are registered, all are allowed.
  213. /// </summary>
  214. public bool CheckAccess (string pathName)
  215. {
  216. Runtime.ValidateRefCounted (this);
  217. return FileSystem_CheckAccess (handle, pathName);
  218. }
  219. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  220. internal static extern uint FileSystem_GetLastModifiedTime (IntPtr handle, string fileName);
  221. /// <summary>
  222. /// Returns the file's last modified time as seconds since 1.1.1970, or 0 if can not be accessed.
  223. /// </summary>
  224. public uint GetLastModifiedTime (string fileName)
  225. {
  226. Runtime.ValidateRefCounted (this);
  227. return FileSystem_GetLastModifiedTime (handle, fileName);
  228. }
  229. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  230. internal static extern bool FileSystem_FileExists (IntPtr handle, string fileName);
  231. /// <summary>
  232. /// Check if a file exists.
  233. /// </summary>
  234. public bool FileExists (string fileName)
  235. {
  236. Runtime.ValidateRefCounted (this);
  237. return FileSystem_FileExists (handle, fileName);
  238. }
  239. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  240. internal static extern bool FileSystem_DirExists (IntPtr handle, string pathName);
  241. /// <summary>
  242. /// Check if a directory exists.
  243. /// </summary>
  244. public bool DirExists (string pathName)
  245. {
  246. Runtime.ValidateRefCounted (this);
  247. return FileSystem_DirExists (handle, pathName);
  248. }
  249. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  250. internal static extern IntPtr FileSystem_GetProgramDir (IntPtr handle);
  251. /// <summary>
  252. /// Return the program's directory. If it does not contain the Urho3D default CoreData and Data directories, and the current working directory does, return the working directory instead.
  253. /// </summary>
  254. private string GetProgramDir ()
  255. {
  256. Runtime.ValidateRefCounted (this);
  257. return Marshal.PtrToStringAnsi (FileSystem_GetProgramDir (handle));
  258. }
  259. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  260. internal static extern IntPtr FileSystem_GetUserDocumentsDir (IntPtr handle);
  261. /// <summary>
  262. /// Return the user documents directory.
  263. /// </summary>
  264. private string GetUserDocumentsDir ()
  265. {
  266. Runtime.ValidateRefCounted (this);
  267. return Marshal.PtrToStringAnsi (FileSystem_GetUserDocumentsDir (handle));
  268. }
  269. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  270. internal static extern IntPtr FileSystem_GetAppPreferencesDir (IntPtr handle, string org, string app);
  271. /// <summary>
  272. /// Return the application preferences directory.
  273. /// </summary>
  274. public string GetAppPreferencesDir (string org, string app)
  275. {
  276. Runtime.ValidateRefCounted (this);
  277. return Marshal.PtrToStringAnsi (FileSystem_GetAppPreferencesDir (handle, org, app));
  278. }
  279. public override StringHash Type {
  280. get {
  281. return UrhoGetType ();
  282. }
  283. }
  284. public override string TypeName {
  285. get {
  286. return GetTypeName ();
  287. }
  288. }
  289. public static StringHash TypeStatic {
  290. get {
  291. return GetTypeStatic ();
  292. }
  293. }
  294. public static string TypeNameStatic {
  295. get {
  296. return GetTypeNameStatic ();
  297. }
  298. }
  299. /// <summary>
  300. /// Return whether is executing engine console commands as OS-specific system command.
  301. /// Or
  302. /// Set whether to execute engine console commands as OS-specific system command.
  303. /// </summary>
  304. public bool ExecuteConsoleCommands {
  305. get {
  306. return GetExecuteConsoleCommands ();
  307. }
  308. set {
  309. SetExecuteConsoleCommands (value);
  310. }
  311. }
  312. /// <summary>
  313. /// Return the absolute current working directory.
  314. /// </summary>
  315. public string CurrentDir {
  316. get {
  317. return GetCurrentDir ();
  318. }
  319. }
  320. /// <summary>
  321. /// Return the program's directory. If it does not contain the Urho3D default CoreData and Data directories, and the current working directory does, return the working directory instead.
  322. /// </summary>
  323. public string ProgramDir {
  324. get {
  325. return GetProgramDir ();
  326. }
  327. }
  328. /// <summary>
  329. /// Return the user documents directory.
  330. /// </summary>
  331. public string UserDocumentsDir {
  332. get {
  333. return GetUserDocumentsDir ();
  334. }
  335. }
  336. }
  337. }