public BaseIOConfig(Stream zStream) { Flags = StreamUtil.ReadIntFromStream(zStream); VirtualKey = StreamUtil.ReadByteFromStream(zStream); StreamUtil.ReadBytesFromStream(zStream, 3); Parameter = StreamUtil.ReadIntFromStream(zStream); }
public BaseIOConfig(Stream zStream) { Flags = StreamUtil.ReadIntFromStream(zStream); VirtualKey = StreamUtil.ReadByteFromStream(zStream); // VirtualKey is only a byte so read the remaining padding bytes for the 32bit int StreamUtil.ReadBytesFromStream(zStream, 3); Parameter = StreamUtil.ReadIntFromStream(zStream); }
/// <summary> /// Loads the remap entries from the specified file /// </summary> /// <param name="sFileName"></param> /// <returns></returns> public List <RemapEntry> LoadFile(string sFileName) { FileStream zFileStream = null; var listConfigs = new List <RemapEntry>(); try { zFileStream = new FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read); var nPrefix = StreamUtil.ReadIntFromStream(zFileStream); if (nPrefix != FILE_DATA_PREFIX) { throw new Exception("{} does not have the correct data prefix. This is likely an unsupported format.".FormatString(sFileName)); } var nDataFormatVersion = StreamUtil.ReadIntFromStream(zFileStream); if (nDataFormatVersion != DATA_FORMAT_VERSION) { throw new Exception("{} indicates an unsupported data format.".FormatString(sFileName)); } while (zFileStream.Position < zFileStream.Length) { listConfigs.Add(new RemapEntry(zFileStream)); } } catch (Exception e) { MessageBox.Show(e.Message); } finally { zFileStream?.Close(); } return(listConfigs); }