public ClusterChain(Fat fat, long startCluster, bool readOnly) : base(readOnly) { this.fat = fat; if (startCluster != 0) { this.fat.TestCluster(startCluster); if (this.fat.IsFreeCluster(startCluster)) { throw new ArgumentException( "cluster " + startCluster + " is free"); } } device = fat.GetDevice(); dataOffset = FatUtils.GetFilesOffset(fat.GetBootSector()); this.startCluster = startCluster; clusterSize = fat.GetBootSector().GetBytesPerCluster(); }
public static ClusterChainDirectory CreateRoot(Fat fat) { if (fat.GetFatType() != FatType.BaseFat32) { throw new ArgumentException( "only FAT32 stores root directory in a cluster chain"); } var bs = (Fat32BootSector)fat.GetBootSector(); var cc = new ClusterChain(fat, false); cc.SetChainLength(1); bs.SetRootDirFirstCluster(cc.GetStartCluster()); var result = new ClusterChainDirectory(cc, true); result.Flush(); return(result); }