Exemplo n.º 1
0
		public FDSDisk(BinaryReader r)
		{
			long startpos = r.BaseStream.Position;
			long endpos = startpos + 65500;

			if (r.ReadByte() != 1)
				throw new InvalidOperationException("Bad Block Code");

			if (!r.ReadBytes(14).SequenceEqual(Check))
				throw new InvalidOperationException("Bad Verification Code");

			// one could do quite a bit with this data
			HeaderData = r.ReadBytes(41);

			if (r.ReadByte() != 2)
				throw new InvalidOperationException("Bad Block Code");

			int nfiles = r.ReadByte();

			while (nfiles > 0)
			{
				Chunks.Add(new FDSChunk(r));
				nfiles--;
			}
			if (r.BaseStream.Position > endpos)
				throw new InvalidOperationException("Disk too long");

			long usedpos = r.BaseStream.Position;
			while (true)
			{
				try
				{
					var chunk = new FDSChunk(r) { Hidden = true };
					if (r.BaseStream.Position <= endpos)
					{
						Chunks.Add(chunk);
						usedpos = r.BaseStream.Position;
					}
					else
					{
						break;
					}
				}
				catch { break; }
			}

			r.BaseStream.Seek(usedpos, SeekOrigin.Begin);
			ExtraData = r.ReadBytes((int)(endpos - usedpos));
		}
Exemplo n.º 2
0
        public FDSDisk(BinaryReader r)
        {
            long startpos = r.BaseStream.Position;
            long endpos   = startpos + 65500;

            if (r.ReadByte() != 1)
            {
                throw new InvalidOperationException("Bad Block Code");
            }

            if (!r.ReadBytes(14).SequenceEqual(Check))
            {
                throw new InvalidOperationException("Bad Verification Code");
            }

            // one could do quite a bit with this data
            HeaderData = r.ReadBytes(41);

            if (r.ReadByte() != 2)
            {
                throw new InvalidOperationException("Bad Block Code");
            }

            int nfiles = r.ReadByte();

            while (nfiles > 0)
            {
                Chunks.Add(new FDSChunk(r));
                nfiles--;
            }
            if (r.BaseStream.Position > endpos)
            {
                throw new InvalidOperationException("Disk too long");
            }

            long usedpos = r.BaseStream.Position;

            while (true)
            {
                try
                {
                    var chunk = new FDSChunk(r)
                    {
                        Hidden = true
                    };
                    if (r.BaseStream.Position <= endpos)
                    {
                        Chunks.Add(chunk);
                        usedpos = r.BaseStream.Position;
                    }
                    else
                    {
                        break;
                    }
                }
                catch { break; }
            }

            r.BaseStream.Seek(usedpos, SeekOrigin.Begin);
            ExtraData = r.ReadBytes((int)(endpos - usedpos));
        }