protected override void Write(MemoryStream data) { var toWrite = (int)(data.Length - data.Position); Chain.WriteData(0, data); var trueSize = Chain.GetLengthOnDisk(); /* TODO: check if the code below is really needed */ if (trueSize > toWrite) { var rest = (int)(trueSize - toWrite); var fill = new MemoryStream(rest); Chain.WriteData(toWrite, fill); } }
internal static FatFile Get(Fat fat, FatDirectoryEntry entry) { if (entry.IsDirectory()) { throw new ArgumentException(entry + " is a directory"); } var cc = new ClusterChain( fat, entry.GetStartCluster(), entry.IsReadonlyFlag()); if (entry.GetLength() > cc.GetLengthOnDisk()) { throw new IOException( "entry is larger than associated cluster chain"); } return(new FatFile(entry, cc)); }
internal ClusterChainDirectory(ClusterChain chain, bool isRoot) : base((int)(chain.GetLengthOnDisk() / FatDirectoryEntry.SIZE), chain.IsReadOnly(), isRoot) { this.Chain = chain; }