1
0
mirror of https://github.com/livingcomputermuseum/IFS.git synced 2026-02-08 01:02:25 +00:00

Progress made; updated to work with Contralto, initial stubs for CopyDisk. Misc services work.

This commit is contained in:
Josh Dersch
2016-01-27 17:24:51 -08:00
parent 2badecda6d
commit 32beacdca8
16 changed files with 1179 additions and 222 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -19,7 +20,7 @@ namespace IFS
throw new InvalidOperationException("Max length for a BCPL string is 255 characters.");
}
_string = new byte[_string.Length];
_string = new byte[s.Length];
// We simply take the low 8-bits of each Unicode character and stuff it into the
// byte array. This works fine for the ASCII subset of Unicode but obviously
@@ -53,6 +54,45 @@ namespace IFS
Array.Copy(rawData, 1, _string, 0, rawData.Length - 1);
}
/// <summary>
/// Build a new BCPL string from the raw representation at the given position in the array
/// </summary>
/// <param name="rawData"></param>
public BCPLString(byte[] rawData, int offset)
{
int length = rawData[offset];
// Sanity check that BCPL length fits within specified array
if (length > rawData.Length - offset)
{
throw new InvalidOperationException("BCPL length data is invalid.");
}
_string = new byte[length];
Array.Copy(rawData, offset + 1, _string, 0, length);
}
public BCPLString(BSPChannel channel)
{
byte length = channel.ReadByte();
_string = new byte[length];
channel.Read(ref _string, length);
}
public BCPLString(Stream s)
{
byte length = (byte)s.ReadByte();
_string = new byte[length];
s.Read(_string, 0, length);
}
public int Length
{
get { return _string.Length; }
}
/// <summary>
/// Returns a native representation of the BCPL string
/// </summary>