Example #1
0
        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);
        }
Example #2
0
 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);
     }
 }