@@ -123,13 +123,15 @@ public static bool EmbeddedResourceExists(string resourceName, Assembly assembly
123123 }
124124 return false ;
125125 }
126+
126127 /// <summary>
127- /// Convert an array of bytes to hexadecimal.
128+ /// Convert an array of bytes to hexadecimal characters .
128129 /// </summary>
129130 public static string ToHex ( byte [ ] data )
130131 {
131132 return BitConverter . ToString ( data ) . Replace ( "-" , "" ) ;
132133 }
134+
133135 /// <summary>
134136 /// Create a SHA256 based off the <paramref name="content"/> provided.
135137 /// </summary>
@@ -182,7 +184,7 @@ public static string CreateSha256Hash(string content)
182184 /// Allocates a new console for the calling process.
183185 /// </summary>
184186 /// <returns>
185- /// When ` false` , the function has failed. You can call <see href="https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</see> to get more details.</returns>
187+ /// When <see langword=" false"/> , the function has failed. You can call <see href="https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</see> to get more details.</returns>
186188 [ DllImport ( "kernel32.dll" , SetLastError = true ) ]
187189 [ return : MarshalAs ( UnmanagedType . Bool ) ]
188190 public static extern bool AllocConsole ( ) ;
@@ -235,6 +237,7 @@ public static string FormatLineEndings(string content, string lineEnding="\n")
235237
236238 return string . Join ( lineEnding , lines ) ;
237239 }
240+
238241 /// <summary>
239242 /// Trim an Array to make sure it's length doesn't exceed the <paramref name="length"/> provided.
240243 /// </summary>
@@ -298,7 +301,7 @@ public static float[] ToFloatArray(int[] array)
298301 public static List < T > GetEnumList < T > ( )
299302 {
300303 T [ ] array = ( T [ ] ) Enum . GetValues ( typeof ( T ) ) ;
301- List < T > list = new List < T > ( array ) ;
304+ var list = new List < T > ( array ) ;
302305 return list ;
303306 }
304307 /// <summary>
@@ -322,13 +325,21 @@ public static long GetNanoseconds()
322325 /// <summary>
323326 /// Get microseconds from <see cref="Stopwatch.GetTimestamp"/>
324327 /// </summary>
325- /// <returns></returns>
326328 public static long GetMicroseconds ( )
327329 {
328330 double timestamp = Stopwatch . GetTimestamp ( ) ;
329331 double microseconds = 1_000_000.0 * timestamp / Stopwatch . Frequency ;
330332 return ( long ) microseconds ;
331333 }
334+ /// <summary>
335+ /// Get milliseconds from <see cref="Stopwatch.GetTimestamp"/>
336+ /// </summary>
337+ public static long GetMilliseconds ( )
338+ {
339+ double timestamp = Stopwatch . GetTimestamp ( ) ;
340+ double microseconds = 1_000.0 * timestamp / Stopwatch . Frequency ;
341+ return ( long ) microseconds ;
342+ }
332343 public static string ToBase62 ( ulong number )
333344 {
334345 var alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
@@ -735,7 +746,7 @@ public static void RecursiveMove(string oldDirectory, string newDirectory)
735746 /// </summary>
736747 public static string GetExtension ( string filename )
737748 {
738- return Path . GetExtension ( filename ) . Trim ( '.' ) . ToLower ( ) ;
749+ return Path . GetExtension ( filename ) . TrimStart ( '.' ) . ToLower ( ) ;
739750 }
740751
741752 public static int GetMaxPathLength ( string directory )
@@ -812,7 +823,6 @@ public static void CreateBackup(string filename)
812823 string backupFilename = filename + @"." + DateTime . Now . Ticks + @".bak" ;
813824 if ( File . Exists ( filename ) && ! File . Exists ( backupFilename ) )
814825 {
815- // Debug.Log(@"Backup created: " + backupFilename);
816826 File . Move ( filename , backupFilename ) ;
817827 }
818828 }
@@ -828,23 +838,6 @@ public static string GetRelativePath(string path, string folder)
828838 return path . Substring ( folder . Length + 1 ) ;
829839 }
830840
831- public static string GetTempPath ( string suffix = "" )
832- {
833- string directory = Path . Combine ( Path . GetTempPath ( ) , @"osu!" ) ;
834- Directory . CreateDirectory ( directory ) ;
835- return Path . Combine ( directory , suffix ) ;
836- }
837-
838- /// <summary>
839- /// Returns the path without the extension of the file.
840- /// Contrarily to Path.GetFileNameWithoutExtension, it keeps the path to the file ("sb/triangle.png" becomes "sb/triangle" and not "triangle")
841- /// </summary>
842- public static string StripExtension ( string filepath )
843- {
844- int dotIndex = filepath . LastIndexOf ( '.' ) ;
845- return dotIndex == - 1 ? filepath : filepath . Substring ( 0 , dotIndex ) ;
846- }
847-
848841 public static string FormatHeader ( string content , int screenWidth = 80 , char padChar = '=' )
849842 {
850843 int halfWidth = Convert . ToInt32 ( Math . Floor ( screenWidth / 2.0f ) ) ;
0 commit comments