internal bool SetFile(cFile NewFile) { if (!Metadata.Flags.Directory) { this.File = NewFile; return(true); } else { return(false); } }
internal cFileSystemItem(string NewName, string NewExtention, cFileFlags NewFlags, bool IsRootDirectory) { if (NewFlags.Directory) { Items = new List <cFileSystemItem>(); } else { File = new cFile(); } Metadata = new cDirectoryEntry(NewName, NewExtention, NewFlags); IsRoot = IsRootDirectory; }
private bool ConvertEntrys(ushort SectorNumber, cFileSystemItem ItemToFill, uint Size) { if (ItemToFill.IsDirectory()) { //ignore the first Entry, as it is isn't displayed in the logical structure int SubIndex = ItemToFill.Metadata.GetBinaryEntrySize(); bool run = true; while (run) { if (HeaderVerifier.IsValidDirectoryEntry(InputFloppy.Sectors[SectorNumber], SubIndex, SectorNumber, InputFAT)) { //TODO: Read/write the datetimes cFileFlags Flags = new cFileFlags(); Flags.ReadFromBinary((byte)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 5]); ushort[] Data = new ushort[4]; Data[0] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 0]; Data[1] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 1]; Data[2] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 2]; Data[3] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 3]; string Name = cFileSigConverter.ConvertToFileName(Data); Data = new ushort[2]; Data[0] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 4]; Data[1] = InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 5]; string Extention = cFileSigConverter.ConvertToFileExtention(Data); cFileSystemItem NewItem = new cFileSystemItem(Name, Extention, Flags, false); Size = (uint)((uint)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 13] << 16 | (uint)InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 12]); if (ConvertEntrys(InputFloppy.Sectors[SectorNumber].Memory[SubIndex + 14], NewItem, Size)) { ItemToFill.AddItem(NewItem); } SubIndex += ItemToFill.Metadata.GetBinaryEntrySize(); if (SubIndex >= InputFAT.GetSectorSize()) { SubIndex = 0; SectorNumber = InputFAT.NextSector(SectorNumber); if (SectorNumber >= 0xFFF0) { run = false; } } } else { run = false; } } return(true); } else { List <ushort> Data = new List <ushort>(); bool run = true; uint i = 0; while (run) { int subIndex = 0; while (subIndex < 512 && i < Size) { Data.Add(InputFloppy.Sectors[SectorNumber].Memory[subIndex]); i++; subIndex++; } SectorNumber = InputFAT.NextSector(SectorNumber); if (SectorNumber >= 0xFFF0) { run = false; } } cFile Newfile = new cFile(); Newfile.SetFileData(Data); ItemToFill.SetFile(Newfile); return(true); } }