예제 #1
0
 private DirectoryEntry(DirectoryRecord record, DirectoryEntry parent)
 {
     archive     = parent.archive;
     Name        = record.name;
     flags       = record.flags;
     this.record = record;
 }
예제 #2
0
        public void CreateDirectory(string name, string path)
        {
            DirectoryRecord n = new DirectoryRecord(name);

            n.flags = 1;
            (GetByPath(path) as DirectoryRecord).Add(n);
            return;
        }
예제 #3
0
 internal DirectoryEntry(DirectoryRecord record, Archive archive)
 {
     this.archive = archive;
     Name         = record.name;
     flags        = record.flags;
     this.record  = record;
     Fullfill();
 }
예제 #4
0
        public void CreateFile(string path, string name, byte[] data)
        {
            DirectoryRecord rec = GetByPath(path) as DirectoryRecord;
            FileRecord      fr  = new FileRecord(name, end);

            fr.length = data.Length;
            rec.Add(fr);
            baseStream.Seek(end, SeekOrigin.Begin);
            baseStream.Write(data, 0, data.Length);
            end += data.Length;
        }
예제 #5
0
 public Archive(Stream s)
 {
     baseStream = s;
     root       = new DirectoryRecord("/");
     br         = new BinaryReader(s);
     bw         = new BinaryWriter(s);
     if (s.Length < 16)
     {
         baseStream.Write(new byte[] { 0, 0, 0, 0, 0x0c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 16);
     }
     ReadFileSystem();
 }
예제 #6
0
 private void SaveRecord(Record rec)
 {
     bw.Write(rec.flags);
     bw.Write(rec.name);
     if ((rec.flags & 1) == 1)
     {
         DirectoryRecord dr = rec as DirectoryRecord;
         bw.Write(dr.Count);
         foreach (string key in dr.records.Keys)
         {
             SaveRecord(dr.records[key]);
         }
     }
     else
     {
         bw.Write((rec as FileRecord).location);
         bw.Write((rec as FileRecord).length);
     }
 }
예제 #7
0
        private void ParseNext()
        {
            int    flags = br.ReadInt32();
            string name  = br.ReadString();

            name = name.Replace("\0", "");
            if ((flags & 1) == 0)
            {
                long       position = br.ReadInt64();
                long       length   = br.ReadInt64();
                FileRecord rec      = new FileRecord(name, position);
                rec.length = length;
                AddFile(name, rec);
            }
            else
            {
                DirectoryRecord rec = new DirectoryRecord(name);
                AddDirectory(name, rec);
                pathes.Add(name);
                ParseDirectory();
                pathes.RemoveAt(pathes.Count - 1);
            }
        }
예제 #8
0
        private void AddFile(string name, FileRecord record)
        {
            DirectoryRecord rec = GetByPath(CombinePath()) as DirectoryRecord;

            rec.Add(record);
        }
예제 #9
0
        public DirectoryEntry GetDirectory(string path)
        {
            DirectoryRecord record = GetByPath(path) as DirectoryRecord;

            return(new DirectoryEntry(record, this));
        }