You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

431 lines
20 KiB

  1. <!DOCTYPE html>
  2. <!--[if IE]><![endif]-->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <title>Class Utils
  8. </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class Utils
  11. ">
  12. <meta name="generator" content="docfx 2.42.4.0">
  13. <link rel="shortcut icon" href="../favicon.ico">
  14. <link rel="stylesheet" href="../styles/docfx.vendor.css">
  15. <link rel="stylesheet" href="../styles/docfx.css">
  16. <link rel="stylesheet" href="../styles/main.css">
  17. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  18. <meta property="docfx:navrel" content="../toc.html">
  19. <meta property="docfx:tocrel" content="toc.html">
  20. <meta property="docfx:rel" content="../">
  21. <meta property="docfx:newtab" content="true">
  22. </head> <body data-spy="scroll" data-target="#affix" data-offset="120">
  23. <div id="wrapper">
  24. <header>
  25. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  26. <div class="container">
  27. <div class="navbar-header">
  28. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  29. <span class="sr-only">Toggle navigation</span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. <span class="icon-bar"></span>
  33. </button>
  34. <a class="navbar-brand" href="../index.html">
  35. <img id="logo" class="svg" src="../logo.svg" alt="">
  36. </a>
  37. </div>
  38. <div class="collapse navbar-collapse" id="navbar">
  39. <form class="navbar-form navbar-right" role="search" id="search">
  40. <div class="form-group">
  41. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  42. </div>
  43. </form>
  44. </div>
  45. </div>
  46. </nav>
  47. <div class="subnav navbar navbar-default">
  48. <div class="container hide-when-search" id="breadcrumb">
  49. <ul class="breadcrumb">
  50. <li></li>
  51. </ul>
  52. </div>
  53. </div>
  54. </header>
  55. <div class="container body-content">
  56. <div id="search-results">
  57. <div class="search-list"></div>
  58. <div class="sr-items">
  59. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  60. </div>
  61. <ul id="pagination"></ul>
  62. </div>
  63. </div>
  64. <div role="main" class="container body-content hide-when-search">
  65. <div class="sidenav hide-when-search">
  66. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  67. <div class="sidetoggle collapse" id="sidetoggle">
  68. <div id="sidetoc"></div>
  69. </div>
  70. </div>
  71. <div class="article row grid-right">
  72. <div class="col-md-10">
  73. <article class="content wrap" id="_content" data-uid="IPA.Utilities.Utils">
  74. <h1 id="IPA_Utilities_Utils" data-uid="IPA.Utilities.Utils" class="text-break">Class Utils
  75. </h1>
  76. <div class="markdown level0 summary"><p>A class providing static utility functions that in any other language would just <em>exist</em>.</p>
  77. </div>
  78. <div class="markdown level0 conceptual"></div>
  79. <div class="inheritance">
  80. <h5>Inheritance</h5>
  81. <div class="level0"><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object">Object</a></div>
  82. <div class="level1"><span class="xref">Utils</span></div>
  83. </div>
  84. <div class="inheritedMembers">
  85. <h5>Inherited Members</h5>
  86. <div>
  87. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.tostring#System_Object_ToString">Object.ToString()</a>
  88. </div>
  89. <div>
  90. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.equals#System_Object_Equals_System_Object_">Object.Equals(Object)</a>
  91. </div>
  92. <div>
  93. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.equals#System_Object_Equals_System_Object_System_Object_">Object.Equals(Object, Object)</a>
  94. </div>
  95. <div>
  96. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.referenceequals#System_Object_ReferenceEquals_System_Object_System_Object_">Object.ReferenceEquals(Object, Object)</a>
  97. </div>
  98. <div>
  99. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.gethashcode#System_Object_GetHashCode">Object.GetHashCode()</a>
  100. </div>
  101. <div>
  102. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.gettype#System_Object_GetType">Object.GetType()</a>
  103. </div>
  104. <div>
  105. <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.object.memberwiseclone#System_Object_MemberwiseClone">Object.MemberwiseClone()</a>
  106. </div>
  107. </div>
  108. <h6><strong>Namespace</strong>: <a class="xref" href="IPA.Utilities.html">IPA.Utilities</a></h6>
  109. <h6><strong>Assembly</strong>: IPA.Loader.dll</h6>
  110. <h5 id="IPA_Utilities_Utils_syntax">Syntax</h5>
  111. <div class="codewrapper">
  112. <pre><code class="lang-csharp hljs">public static class Utils</code></pre>
  113. </div>
  114. <h3 id="methods">Methods
  115. </h3>
  116. <span class="small pull-right mobile-hide">
  117. <span class="divider">|</span>
  118. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils_ByteArrayToString_System_Byte___.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils.ByteArrayToString(System.Byte%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  119. </span>
  120. <span class="small pull-right mobile-hide">
  121. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L31">View Source</a>
  122. </span>
  123. <a id="IPA_Utilities_Utils_ByteArrayToString_" data-uid="IPA.Utilities.Utils.ByteArrayToString*"></a>
  124. <h4 id="IPA_Utilities_Utils_ByteArrayToString_System_Byte___" data-uid="IPA.Utilities.Utils.ByteArrayToString(System.Byte[])">ByteArrayToString(Byte[])</h4>
  125. <div class="markdown level1 summary"><p>Converts a byte array to a hex string.</p>
  126. </div>
  127. <div class="markdown level1 conceptual"></div>
  128. <h5 class="decalaration">Declaration</h5>
  129. <div class="codewrapper">
  130. <pre><code class="lang-csharp hljs">public static string ByteArrayToString(byte[] ba)</code></pre>
  131. </div>
  132. <h5 class="parameters">Parameters</h5>
  133. <table class="table table-bordered table-striped table-condensed">
  134. <thead>
  135. <tr>
  136. <th>Type</th>
  137. <th>Name</th>
  138. <th>Description</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <tr>
  143. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.byte">Byte</a>[]</td>
  144. <td><span class="parametername">ba</span></td>
  145. <td><p>the byte array</p>
  146. </td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. <h5 class="returns">Returns</h5>
  151. <table class="table table-bordered table-striped table-condensed">
  152. <thead>
  153. <tr>
  154. <th>Type</th>
  155. <th>Description</th>
  156. </tr>
  157. </thead>
  158. <tbody>
  159. <tr>
  160. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  161. <td><p>the hex form of the array</p>
  162. </td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <span class="small pull-right mobile-hide">
  167. <span class="divider">|</span>
  168. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils_CopyAll_System_IO_DirectoryInfo_System_IO_DirectoryInfo_System_String_System_Func_System_Exception_System_IO_FileInfo_System_Boolean__.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils.CopyAll(System.IO.DirectoryInfo%2CSystem.IO.DirectoryInfo%2CSystem.String%2CSystem.Func%7BSystem.Exception%2CSystem.IO.FileInfo%2CSystem.Boolean%7D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  169. </span>
  170. <span class="small pull-right mobile-hide">
  171. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L92">View Source</a>
  172. </span>
  173. <a id="IPA_Utilities_Utils_CopyAll_" data-uid="IPA.Utilities.Utils.CopyAll*"></a>
  174. <h4 id="IPA_Utilities_Utils_CopyAll_System_IO_DirectoryInfo_System_IO_DirectoryInfo_System_String_System_Func_System_Exception_System_IO_FileInfo_System_Boolean__" data-uid="IPA.Utilities.Utils.CopyAll(System.IO.DirectoryInfo,System.IO.DirectoryInfo,System.String,System.Func{System.Exception,System.IO.FileInfo,System.Boolean})">CopyAll(DirectoryInfo, DirectoryInfo, String, Func&lt;Exception, FileInfo, Boolean&gt;)</h4>
  175. <div class="markdown level1 summary"><p>Copies all files from <code data-dev-comment-type="paramref" class="paramref">source</code> to <code data-dev-comment-type="paramref" class="paramref">target</code>.</p>
  176. </div>
  177. <div class="markdown level1 conceptual"></div>
  178. <h5 class="decalaration">Declaration</h5>
  179. <div class="codewrapper">
  180. <pre><code class="lang-csharp hljs">public static void CopyAll(DirectoryInfo source, DirectoryInfo target, string appendFileName = &quot;&quot;, Func&lt;Exception, FileInfo, bool&gt; onCopyException = null)</code></pre>
  181. </div>
  182. <h5 class="parameters">Parameters</h5>
  183. <table class="table table-bordered table-striped table-condensed">
  184. <thead>
  185. <tr>
  186. <th>Type</th>
  187. <th>Name</th>
  188. <th>Description</th>
  189. </tr>
  190. </thead>
  191. <tbody>
  192. <tr>
  193. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.io.directoryinfo">DirectoryInfo</a></td>
  194. <td><span class="parametername">source</span></td>
  195. <td><p>the source directory</p>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.io.directoryinfo">DirectoryInfo</a></td>
  200. <td><span class="parametername">target</span></td>
  201. <td><p>the destination directory</p>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  206. <td><span class="parametername">appendFileName</span></td>
  207. <td><p>the filename of the file to append together</p>
  208. </td>
  209. </tr>
  210. <tr>
  211. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.func-3">Func</a>&lt;<a class="xref" href="https://docs.microsoft.com/dotnet/api/system.exception">Exception</a>, <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.io.fileinfo">FileInfo</a>, <a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a>&gt;</td>
  212. <td><span class="parametername">onCopyException</span></td>
  213. <td><p>a delegate called when there is an error copying. Return true to keep going.</p>
  214. </td>
  215. </tr>
  216. </tbody>
  217. </table>
  218. <span class="small pull-right mobile-hide">
  219. <span class="divider">|</span>
  220. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils_GetRelativePath_System_String_System_String_.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils.GetRelativePath(System.String%2CSystem.String)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  221. </span>
  222. <span class="small pull-right mobile-hide">
  223. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L73">View Source</a>
  224. </span>
  225. <a id="IPA_Utilities_Utils_GetRelativePath_" data-uid="IPA.Utilities.Utils.GetRelativePath*"></a>
  226. <h4 id="IPA_Utilities_Utils_GetRelativePath_System_String_System_String_" data-uid="IPA.Utilities.Utils.GetRelativePath(System.String,System.String)">GetRelativePath(String, String)</h4>
  227. <div class="markdown level1 summary"><p>Gets a path relative to the provided folder.</p>
  228. </div>
  229. <div class="markdown level1 conceptual"></div>
  230. <h5 class="decalaration">Declaration</h5>
  231. <div class="codewrapper">
  232. <pre><code class="lang-csharp hljs">public static string GetRelativePath(string file, string folder)</code></pre>
  233. </div>
  234. <h5 class="parameters">Parameters</h5>
  235. <table class="table table-bordered table-striped table-condensed">
  236. <thead>
  237. <tr>
  238. <th>Type</th>
  239. <th>Name</th>
  240. <th>Description</th>
  241. </tr>
  242. </thead>
  243. <tbody>
  244. <tr>
  245. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  246. <td><span class="parametername">file</span></td>
  247. <td><p>the file to relativize</p>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  252. <td><span class="parametername">folder</span></td>
  253. <td><p>the source folder</p>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <h5 class="returns">Returns</h5>
  259. <table class="table table-bordered table-striped table-condensed">
  260. <thead>
  261. <tr>
  262. <th>Type</th>
  263. <th>Description</th>
  264. </tr>
  265. </thead>
  266. <tbody>
  267. <tr>
  268. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  269. <td><p>a path to get from <code data-dev-comment-type="paramref" class="paramref">folder</code> to <code data-dev-comment-type="paramref" class="paramref">file</code></p>
  270. </td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <span class="small pull-right mobile-hide">
  275. <span class="divider">|</span>
  276. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils_StringToByteArray_System_String_.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils.StringToByteArray(System.String)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  277. </span>
  278. <span class="small pull-right mobile-hide">
  279. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L17">View Source</a>
  280. </span>
  281. <a id="IPA_Utilities_Utils_StringToByteArray_" data-uid="IPA.Utilities.Utils.StringToByteArray*"></a>
  282. <h4 id="IPA_Utilities_Utils_StringToByteArray_System_String_" data-uid="IPA.Utilities.Utils.StringToByteArray(System.String)">StringToByteArray(String)</h4>
  283. <div class="markdown level1 summary"><p>Converts a hex string to a byte array.</p>
  284. </div>
  285. <div class="markdown level1 conceptual"></div>
  286. <h5 class="decalaration">Declaration</h5>
  287. <div class="codewrapper">
  288. <pre><code class="lang-csharp hljs">public static byte[] StringToByteArray(string hex)</code></pre>
  289. </div>
  290. <h5 class="parameters">Parameters</h5>
  291. <table class="table table-bordered table-striped table-condensed">
  292. <thead>
  293. <tr>
  294. <th>Type</th>
  295. <th>Name</th>
  296. <th>Description</th>
  297. </tr>
  298. </thead>
  299. <tbody>
  300. <tr>
  301. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.string">String</a></td>
  302. <td><span class="parametername">hex</span></td>
  303. <td><p>the hex stream</p>
  304. </td>
  305. </tr>
  306. </tbody>
  307. </table>
  308. <h5 class="returns">Returns</h5>
  309. <table class="table table-bordered table-striped table-condensed">
  310. <thead>
  311. <tr>
  312. <th>Type</th>
  313. <th>Description</th>
  314. </tr>
  315. </thead>
  316. <tbody>
  317. <tr>
  318. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.byte">Byte</a>[]</td>
  319. <td><p>the corresponding byte array</p>
  320. </td>
  321. </tr>
  322. </tbody>
  323. </table>
  324. <span class="small pull-right mobile-hide">
  325. <span class="divider">|</span>
  326. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils_UnsafeCompare_System_Byte___System_Byte___.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils.UnsafeCompare(System.Byte%5B%5D%2CSystem.Byte%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  327. </span>
  328. <span class="small pull-right mobile-hide">
  329. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L49">View Source</a>
  330. </span>
  331. <a id="IPA_Utilities_Utils_UnsafeCompare_" data-uid="IPA.Utilities.Utils.UnsafeCompare*"></a>
  332. <h4 id="IPA_Utilities_Utils_UnsafeCompare_System_Byte___System_Byte___" data-uid="IPA.Utilities.Utils.UnsafeCompare(System.Byte[],System.Byte[])">UnsafeCompare(Byte[], Byte[])</h4>
  333. <div class="markdown level1 summary"><p>Uses unsafe code to compare 2 byte arrays quickly.</p>
  334. </div>
  335. <div class="markdown level1 conceptual"></div>
  336. <h5 class="decalaration">Declaration</h5>
  337. <div class="codewrapper">
  338. <pre><code class="lang-csharp hljs">public static bool UnsafeCompare(byte[] a1, byte[] a2)</code></pre>
  339. </div>
  340. <h5 class="parameters">Parameters</h5>
  341. <table class="table table-bordered table-striped table-condensed">
  342. <thead>
  343. <tr>
  344. <th>Type</th>
  345. <th>Name</th>
  346. <th>Description</th>
  347. </tr>
  348. </thead>
  349. <tbody>
  350. <tr>
  351. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.byte">Byte</a>[]</td>
  352. <td><span class="parametername">a1</span></td>
  353. <td><p>array 1</p>
  354. </td>
  355. </tr>
  356. <tr>
  357. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.byte">Byte</a>[]</td>
  358. <td><span class="parametername">a2</span></td>
  359. <td><p>array 2</p>
  360. </td>
  361. </tr>
  362. </tbody>
  363. </table>
  364. <h5 class="returns">Returns</h5>
  365. <table class="table table-bordered table-striped table-condensed">
  366. <thead>
  367. <tr>
  368. <th>Type</th>
  369. <th>Description</th>
  370. </tr>
  371. </thead>
  372. <tbody>
  373. <tr>
  374. <td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
  375. <td><p>whether or not they are byte-for-byte equal</p>
  376. </td>
  377. </tr>
  378. </tbody>
  379. </table>
  380. </article>
  381. </div>
  382. <div class="hidden-sm col-md-2" role="complementary">
  383. <div class="sideaffix">
  384. <div class="contribution">
  385. <ul class="nav">
  386. <li>
  387. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/new/5a71e5c1482c458c20962edfe6c9ed9637c2e9a7/apiSpec/new?filename=IPA_Utilities_Utils.md&amp;value=---%0Auid%3A%20IPA.Utilities.Utils%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
  388. </li>
  389. <li>
  390. <a href="https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/blob/master/IPA.Loader/Utilities/Utils.cs/#L10" class="contribution-link">View Source</a>
  391. </li>
  392. </ul>
  393. </div>
  394. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  395. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  396. </nav>
  397. </div>
  398. </div>
  399. </div>
  400. </div>
  401. <footer>
  402. <div class="grad-bottom"></div>
  403. <div class="footer">
  404. <div class="container">
  405. <span class="pull-right">
  406. <a href="#top">Back to top</a>
  407. </span>
  408. <span>Generated by <strong>DocFX</strong></span>
  409. </div>
  410. </div>
  411. </footer>
  412. </div>
  413. <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
  414. <script type="text/javascript" src="../styles/docfx.js"></script>
  415. <script type="text/javascript" src="../styles/main.js"></script>
  416. </body>
  417. </html>