コード例 #1
0
ファイル: Program.cs プロジェクト: Cratez/SimpleFS
 static void CheckBytes(string name1, SECTOR s1, string name2, SECTOR s2)
 {
     if (!Compare(s1.RawBytes, s2.RawBytes))
     {
         throw new Exception($"Sectors {name1} and {name2} are not equal");
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Cratez/SimpleFS
 static void CheckSectorBytes(SECTOR lhs, SECTOR rhs)
 {
     if (!Compare(lhs.RawBytes, rhs.RawBytes))
     {
         Console.WriteLine($"{lhs.Type.ToString()} sectors are not equal!");
     }
     else
     {
         Console.WriteLine($"{lhs.Type.ToString()} sectors are equal!");
     }
 }
コード例 #3
0
ファイル: VirtualDrive.cs プロジェクト: Cratez/SimpleFS
        public int[] GetNextFreeSectors(int count)
        {
            //array for our free sectors...
            int[] freeSectors = new int[count];

            //search fof free sectors...
            for (int i = 0; i < mDisk.SectorCount; i++)
            {
                byte[] raw = mDisk.ReadSector(i);
                if (SECTOR.GetTypeFromBytes(raw) == SECTOR.SectorType.FREE_SECTOR)
                {
                    //add the free sector
                    freeSectors[--count] = i;

                    //enough?
                    if (count <= 0)
                    {
                        return(freeSectors);
                    }
                }
            }
            throw new Exception("Disk is full!");
        }