Minor fixups

This commit is contained in:
Lyssa
2025-04-07 19:19:24 +04:00
parent 3f1c878318
commit 0c8b1efaa9
25 changed files with 168 additions and 194 deletions

View File

@ -4,9 +4,9 @@ namespace LibTSforge.PhysicalStore
public enum BlockType : uint
{
NONE,
NONE, // unused
NAMED,
ATTRIBUTE,
ATTRIBUTE, //unused
TIMER
}

View File

@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
using System;
using System.Collections.Generic;
using System.IO;
using LibTSforge.Crypto;
using Crypto;
public class ModernBlock
{
@ -93,7 +93,7 @@ namespace LibTSforge.PhysicalStore
public sealed class PhysicalStoreModern : IPhysicalStore
{
private byte[] PreHeaderBytes = new byte[] { };
private byte[] PreHeaderBytes = { };
private readonly Dictionary<string, List<ModernBlock>> Data = new Dictionary<string, List<ModernBlock>>();
private readonly FileStream TSFile;
private readonly PSVersion Version;
@ -281,40 +281,44 @@ namespace LibTSforge.PhysicalStore
public void DeleteBlock(string key, string value)
{
if (Data.ContainsKey(key))
if (!Data.ContainsKey(key))
{
List<ModernBlock> blocks = Data[key];
foreach (ModernBlock block in blocks)
{
if (block.ValueAsStr == value)
{
blocks.Remove(block);
break;
}
}
Data[key] = blocks;
return;
}
List<ModernBlock> blocks = Data[key];
foreach (ModernBlock block in blocks)
{
if (block.ValueAsStr == value)
{
blocks.Remove(block);
break;
}
}
Data[key] = blocks;
}
public void DeleteBlock(string key, uint value)
{
if (Data.ContainsKey(key))
if (!Data.ContainsKey(key))
{
List<ModernBlock> blocks = Data[key];
foreach (ModernBlock block in blocks)
{
if (block.ValueAsInt == value)
{
blocks.Remove(block);
break;
}
}
Data[key] = blocks;
return;
}
List<ModernBlock> blocks = Data[key];
foreach (ModernBlock block in blocks)
{
if (block.ValueAsInt == value)
{
blocks.Remove(block);
break;
}
}
Data[key] = blocks;
}
public PhysicalStoreModern(string tsPath, bool production, PSVersion version)

View File

@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
using System;
using System.Collections.Generic;
using System.IO;
using LibTSforge.Crypto;
using Crypto;
public class VistaBlock
{
@ -88,7 +88,7 @@ namespace LibTSforge.PhysicalStore
public sealed class PhysicalStoreVista : IPhysicalStore
{
private byte[] PreHeaderBytes = new byte[] { };
private byte[] PreHeaderBytes = { };
private readonly List<VistaBlock> Blocks = new List<VistaBlock>();
private readonly FileStream TSPrimary;
private readonly FileStream TSSecondary;

View File

@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
using System;
using System.Collections.Generic;
using System.IO;
using LibTSforge.Crypto;
using Crypto;
public class Win7Block
{
@ -105,7 +105,7 @@ namespace LibTSforge.PhysicalStore
public sealed class PhysicalStoreWin7 : IPhysicalStore
{
private byte[] PreHeaderBytes = new byte[] { };
private byte[] PreHeaderBytes = { };
private readonly List<Win7Block> Blocks = new List<Win7Block>();
private readonly FileStream TSPrimary;
private readonly FileStream TSSecondary;

View File

@ -74,7 +74,6 @@ namespace LibTSforge.PhysicalStore
public override void Decode(BinaryReader reader)
{
uint type = reader.ReadUInt32();
uint unk_zero = reader.ReadUInt32();
uint lenName = reader.ReadUInt32();
uint lenVal = reader.ReadUInt32();
uint crc = reader.ReadUInt32();
@ -156,7 +155,7 @@ namespace LibTSforge.PhysicalStore
public List<CRCBlock> Blocks = new List<CRCBlock>();
private readonly PSVersion Version;
public void Deserialize(byte[] data)
private void Deserialize(byte[] data)
{
int len = data.Length;