Пример #1
0
 public void resizeDisk(int resize,ref DinnerEntry e)
 {
     for (int i = 0; i < dinners.Length; i++)
         dinners[i].resized = false;
     uint prevsz = e.size;
     e.size = (uint)((int)e.size+resize);
     uint curpos = normpos(e.offset + prevsz);
     uint newpos = normpos(e.offset + e.size);
     setDinner(e);
     if (curpos == newpos) return;
     DinnerEntry ce;
     while (!(ce = findDinnerByOffset(curpos)).isEmpty())
     {
         ce.old_offset = ce.offset;
         ce.offset = newpos;
     //                Console.WriteLine(String.Format("found {0:d} @{1:X8}->@{2:X8} size={3:X4}", ce.id,ce.old_offset,ce.offset, ce.size));
         setDinner(ce);
         curpos += ce.size;
         newpos += ce.size;
         normpos(ref curpos);
         normpos(ref newpos);
     }
     for (int i = 0; i < dinners.Length; i++)
         dinners[i].resized = false;
     //            if (newpos != diskbuf.Length)
     {
         byte[] prevbuf = diskbuf;
         diskbuf=new byte[newpos];
         Array.Copy(prevbuf, diskbuf, e.offset);
         curpos = normpos(e.offset + e.size);
         while (!(ce = findDinnerByOffset(curpos)).isEmpty())
         {
      //                   Console.WriteLine(String.Format("moveing {0:d} {1:X8}->{2:X8} {3:X4}",ce.id,ce.old_offset,ce.offset,ce.size));
             Array.Copy(prevbuf, ce.old_offset, diskbuf, ce.offset, ce.size);
             curpos += ce.size;
             normpos(ref curpos);
             setDinner(ce);
         }
     }
 }
Пример #2
0
 public void setDinner(DinnerEntry e)
 {
     for (int i=0;i<dinners.Length;i++)
         if (dinners[i].id == e.id)
         {
             dinners[i] = e;
             dinners[i].resized = true;
             return;
         }
 }
Пример #3
0
 public bool readDinner()
 {
     FileStream fs = new FileStream(path + disk_file, FileMode.Open);
     diskbuf=new byte[fs.Length];
     fs.Read(diskbuf,0,(int)fs.Length);
     fs.Close();
     BinaryReader br=new BinaryReader(new FileStream(path+dinner_file,FileMode.Open));
     dinnerSize=br.ReadUInt32();
     version = getVersion();
     dinners = new DinnerEntry[dinnerSize];
     for (uint i=0;i<dinnerSize;i++)
         dinners[i]=new DinnerEntry(br,version);
     br.Close();
     return true;
 }