• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ACadSharp/IO/DWG/CRC32StreamHandler.cs
1
using System.IO;
2

3
namespace ACadSharp.IO.DWG
4
{
5
        internal class CRC32StreamHandler : Stream
6
        {
7
                public override bool CanRead => _stream.CanRead;
×
8
                public override bool CanSeek => _stream.CanSeek;
×
9
                public override bool CanWrite => _stream.CanWrite;
×
10
                public override long Length => _stream.Length;
×
11
                public override long Position
12
                {
13
                        get => _stream.Position;
×
14
                        set => _stream.Position = value;
×
15
                }
16

17
                private Stream _stream;
18

19
                public uint Seed => ~_seed;
×
20

21
                private uint _seed;
22

23
                /// <summary>
24
                /// Constructor that creates a magic sequence given an array of bytes.
25
                /// </summary>
26
                /// <param name="arr">Array of 108 bytes</param>
27
                /// <param name="seed"></param>
28
                public CRC32StreamHandler(byte[] arr, uint seed)
×
29
                {
×
30
                        int randSeed = 1;
×
31

32
                        for (int index = 0; index < arr.Length; ++index)
×
33
                        {
×
34
                                randSeed *= 0x343fd;
×
35
                                randSeed += 0x269ec3;
×
36

37
                                byte values = (byte)(randSeed >> 0x10);
×
38
                                arr[index] = (byte)(arr[index] ^ (uint)values);
×
39
                        }
×
40

41
                        _stream = new MemoryStream(arr);
×
42

43
                        _seed = ~seed;
×
44
                }
×
45

46
                public CRC32StreamHandler(Stream stream, uint seed)
×
47
                {
×
48
                        _stream = stream;
×
49
                        //Reverse the bits
50
                        _seed = ~seed;
×
51
                }
×
52

53
                public override void Flush()
54
                {
×
55
                        _stream.Flush();
×
56
                }
×
57

58
                public override int Read(byte[] buffer, int offset, int count)
59
                {
×
60
                        int nbytes = _stream.Read(buffer, offset, count);
×
61
                        int length = offset + count;
×
62

63
                        for (int index = offset; index < length; ++index)
×
64
                        {
×
65
                                _seed = _seed >> 8 ^ CRC.Crc32Table[((int)_seed ^ buffer[index]) & byte.MaxValue];
×
66
                        }
×
67

68
                        return nbytes;
×
69
                }
×
70
                
71
                public override long Seek(long offset, SeekOrigin origin)
72
                {
×
73
                        return _stream.Seek(offset, origin);
×
74
                }
×
75
                
76
                public override void SetLength(long value)
77
                {
×
78
                        _stream.SetLength(value);
×
79
                }
×
80

81
                public override void Write(byte[] buffer, int offset, int count)
82
                {
×
83
                        int num = offset + count;
×
84

85
                        for (int index = offset; index < num; ++index)
×
86
                                _seed = _seed >> 8 ^ CRC.Crc32Table[((int)_seed ^ buffer[index]) & byte.MaxValue];
×
87

88
                        _stream.Write(buffer, offset, count);
×
89
                }
×
90
        }
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc