mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* AppleHFS.cs: Modified to use EndianAwareBinaryReader and PascalToString classes * FileSystemIDandChk.csproj: CToString.cs renamed to StringHandlers.cs * StringHandlers.cs: Added code to convert Pascal string to .NET String git-svn-id: svn://claunia.com/FileSystemIDandChk@14 17725271-3d32-4980-a8cb-9ff532f270ba
39 lines
669 B
C#
39 lines
669 B
C#
using System;
|
|
using System.Text;
|
|
|
|
namespace FileSystemIDandChk
|
|
{
|
|
public static class StringHandlers
|
|
{
|
|
public static string CToString (byte[] CString)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for(int i = 0; i<CString.Length; i++)
|
|
{
|
|
if(CString[i]==0)
|
|
break;
|
|
|
|
sb.Append(Encoding.ASCII.GetString(CString, i, 1));
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string PascalToString (byte[] PascalString)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
byte length = PascalString[0];
|
|
|
|
for(int i = 1; i < length+1; i++)
|
|
{
|
|
sb.Append(Encoding.ASCII.GetString (PascalString, i, 1));
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|
|
|