internal cFileSystem(DiskType ModeOfDisk, cFloppy FloppyToUse) { FAT = new cFAT(ModeOfDisk, FloppyToUse); cFileFlags RootDirFlags = new cFileFlags(); RootDirFlags.Directory = true; RootDirectory = new cFileSystemItem("", "", RootDirFlags, true); WorkingDirectory = RootDirectory; PathToWorkingDirectory = new List <cFileSystemItem>(); PathToWorkingDirectory.Add(RootDirectory); }
internal cBinReader(cFloppy NewFloppy) { InputFloppy = NewFloppy; OutputFloppy = new cFloppy(InputFloppy.Sectors.Length); if (IsBootable(InputFloppy)) { OutputFS = new cFileSystem(DiskType.Bootable, OutputFloppy); OutputFS.FAT.InitFat(); InputFAT = new cFAT(DiskType.Bootable, InputFloppy); } else { OutputFS = new cFileSystem(DiskType.NonBootable, OutputFloppy); OutputFS.FAT.InitFat(); InputFAT = new cFAT(DiskType.NonBootable, InputFloppy); } }
internal ushort ConvertToBinary(cFAT FAT, ushort SupSector) { ushort FirstSector; if (IsDirectory()) { ushort[] BinDataTemp = new ushort[(this.Items.Count + 1) * Metadata.GetBinaryEntrySize()]; ushort[] Temp; int TempIndex = 0; FirstSector = FAT.RegisterSectors(this.GetSizeInSectors(FAT.GetSectorSize(), false)); cFileFlags Flags = new cFileFlags(); Flags.ReadOnly = true; Flags.Directory = true; cFileSystemItem DirUp = new cFileSystemItem("..", "", Flags, false); Temp = DirUp.Metadata.GetDirectoryBinData(SupSector, 0); for (int i = 0; i < Temp.Length; i++) { BinDataTemp[TempIndex] = Temp[i]; TempIndex++; } foreach (cFileSystemItem Item in this.Items) { Temp = Item.Metadata.GetDirectoryBinData(Item.ConvertToBinary(FAT, FirstSector), Item.GetSizeInWordsForDirEntry()); for (int i = 0; i < Temp.Length; i++) { BinDataTemp[TempIndex] = Temp[i]; TempIndex++; } } FAT.WriteData(BinDataTemp, FirstSector); } else { FirstSector = FAT.RegisterSectors(this.GetSizeInSectors(FAT.GetSectorSize(), false)); FAT.WriteData(this.File.GetData(), FirstSector); } return(FirstSector); }
internal static bool IsValidDirectoryEntry(cSector Sector, int SubIndex, ushort SectorIndex, cFAT FAT) { if (SubIndex > Sector.Memory.Length) { return(false); } for (int i = 0; i < 6; i++) { if (Sector.Memory[SubIndex] == 0x0000) //Name { return(false); } } uint TempSize = (uint)(Sector.Memory[SubIndex + 0xC] + (Sector.Memory[SubIndex + 0xD] << 16)); if ((TempSize == 0) && ((Sector.Memory[SubIndex + 0x5] & 0x0010) == 0)) { return(false); } if (FAT.NextSector(SectorIndex) == 0x0000) { return(false); } return(true); }