Esempio n. 1
0
 public bool WriteNewFile(Folder Root, string FilePath, ref int Progress, ref int BlocksToWrite)
 {
     FATX_Browser.FATX.IOReader br = null;
     //Do a try...
     try
     {
         //Get our entry
         EntryData EData = GetNewEntryData(Root, new System.IO.FileInfo(FilePath).Name);
         //Create our entry in the folder
         CreateNewEntry(EData);
         //Create our new fatstuff to get our free blocks
         FATStuff fs = new FATStuff(Root);
         //Get our free blocks
         uint[] blocks = fs.GetFreeBlocks((int)(m.UpToNearestCluster(new System.IO.FileInfo(FilePath).Length, Root.PartInfo.ClusterSize) / Root.PartInfo.ClusterSize), EData.StartingCluster, 0, false);
         //Make a new list for the blocks...
         List<uint> COCKS = blocks.ToList<uint>();
         //Insert the beginning block at the 0 index
         COCKS.Insert(0, EData.StartingCluster);
         //Make the cocks an array
         blocks = COCKS.ToArray();
         //Write the FAT chain
         WriteFATChain(blocks, Root);
         //Create our binary reader to read our file
         br = new FATX_Browser.FATX.IOReader(new System.IO.FileStream(FilePath, System.IO.FileMode.Open));
         for (int i = 0; i < blocks.Length; i++)
         {
             WriteToCluster(m.GetBlockOffset(blocks[i], Root), br.ReadBytes(0x200));
         }
         br.Close();
         return true;
     }
     catch(Exception e)
     {
         try
         {
             br.Close();
         }
         catch { }
         throw e;
     }
 }