public VM_DataSector(DataSector x) { Id = x.Id; Name = x.Name; CheckMark = true; Devices = new ObservableCollection <VM_Device>(); }
private void WriteData(DataSector data) { if (data?.Content == null || data.Content.Length != DataSector.ContentSize) { Write(new byte[DataSector.ContentSize]); } else { Write(data.Content); } }
public void WriteFS(FileSystem fs) { fs.UpdateBitmap(); WriteHeader(fs.Header); var emptyIndex = new IndexNode(); for (long i = 0; i < fs.IndexNodes.LongLength; i++) { WriteIndex(fs.IndexNodes[i] ?? emptyIndex); } WriteBitmap(fs.Bitmap); var emptyData = new DataSector(); for (long i = 0; i < fs.DataSectors.LongLength; i++) { WriteData(fs.DataSectors[i]); } }
private void AddFile(FileInfo file, IndexNode dir) { var node = new IndexNode { ID = FS.GenerateIndexId(), ParentID = dir.ID, Flags = IndexFlags.Valid, Name = file.Name, DataLength = (uint)file.Length }; FS.InsertIndexNode(node); if (file.Length > 0) { using (var fileStream = file.Open(FileMode.Open, FileAccess.Read)) { var buffer = new byte[DataSector.ContentSize]; var read = 0; while ((read = fileStream.Read(buffer, 0, buffer.Length)) > 0) { var sector = new DataSector { Content = new byte[DataSector.ContentSize] }; Array.Copy(buffer, sector.Content, read); var sectorId = FS.InsertDataSector(sector); if (!node.Flags.HasFlag(IndexFlags.HasData)) { node.Flags |= IndexFlags.HasData | IndexFlags.Contigious; node.DataSector = sectorId; } node.DataSectorCount++; } } } }