Esempio n. 1
0
 public Wbfs(Stream stream)
 {
     this.stream    = stream;
     cluster_size   = 1 << stream.Read(9, 1)[0];
     clusters_table = stream.Read((1 << stream.Read(8, 1)[0]) + 0x100, (int)(4699979776 * 2 / cluster_size * 2));
     for (var i = 0; i < clusters_table.Length / 2; i++)
     {
         if (BigEndian.ToUInt16(clusters_table, i * 2) != 0)
         {
             length = (long)(i + 1) * cluster_size;
         }
     }
     length = length <= 4699979776 ? 4699979776 : 8511160320;
 }
Esempio n. 2
0
 public override int Read(byte[] buffer, int offset, int size)
 {
     while (size > 0)
     {
         var cluster_index      = (int)(position / cluster_size);
         var in_cluster_offset  = (int)(position % cluster_size);
         var cluster_wbfs_index = BigEndian.ToUInt16(clusters_table, cluster_index * 2);
         var cluster_copy_size  = Math.Min(cluster_size - in_cluster_offset, size);
         if (cluster_wbfs_index == 0)
         {
             Array.Clear(buffer, offset, cluster_copy_size);
         }
         else
         {
             stream.Read((long)cluster_wbfs_index * cluster_size + in_cluster_offset, buffer, offset, cluster_copy_size);
         }
         offset   += cluster_copy_size;
         size     -= cluster_copy_size;
         position += cluster_copy_size;
     }
     return(size);
 }
Esempio n. 3
0
 public static int ReadBE16(this Stream file, long position)
 {
     return(BigEndian.ToUInt16(file.Read(position, 2), 0));
 }