Esempio n. 1
0
 public FileInfo CreateFile(string filename)
 {
     lock(_sync)
     {
         if (_toc.Entries.Any(t => t.Name.Equals(filename, StringComparison.InvariantCultureIgnoreCase))) throw new IOException("file exists");
         var entry = new TocEntry { Handle = _compoundFile.Allocate(), Name = filename, Length = 0 };
         _toc.Entries.Add(entry);
         WriteToc();
         return entry.ToFileInfo();                
     }
 }
Esempio n. 2
0
 public static TocEntry Create(byte[] item)
 {
     var ret = new TocEntry();
     var enc = new System.Text.UTF8Encoding();
     
     int ix = 0;
     var namelength = BitConverter.ToInt32(item, ix);
     ix += sizeof (Int32);
     ret.Name = enc.GetString(item, ix, namelength);
     ix += namelength;
     ret.Length = BitConverter.ToUInt32(item, ix);
     ix += sizeof (uint);
     ret.Handle = BitConverter.ToUInt32(item, ix);
     return ret;
 }