Beispiel #1
0
        void AddFile(VDFSDirectoryInfo dir, Entry entry)
        {
            string filePath = Path.Combine(dir.Path, entry.Name);

            if (vFiles.TryGetValue(filePath, out VDFSFileInfo other))
            {                         // there is already a file with that path
                if (this.projectVDFS) // this one is more important
                {
                    if (other.Archive.projectVDFS)
                    {
                        if (other.Archive.timeStamp.Value < this.timeStamp.Value)
                        {                                                    // this file is newer
                            other.SetSource(this, entry.JumpTo, entry.Size); // replace
                        }
                    }
                    else
                    {
                        other.SetSource(this, entry.JumpTo, entry.Size); // replace
                    }
                }
                else if (!other.Archive.projectVDFS && other.Archive.timeStamp.Value < this.timeStamp.Value)
                {                                                    // this file is newer
                    other.SetSource(this, entry.JumpTo, entry.Size); // replace
                }
            }
            else
            {
                VDFSFileInfo file = new VDFSFileInfo(filePath, dir, this, entry.JumpTo, entry.Size);
                vFiles.Add(filePath, file);
                dir.FileNames.Add(entry.Name, file);
            }
        }
Beispiel #2
0
        void ReadEntry(BinaryReader br, string name, VDFSDirectoryInfo parent)
        {
            string path = parent == null ? name : Path.Combine(parent.Path, name);

            if (!vDirs.TryGetValue(path, out VDFSDirectoryInfo dir))
            {
                dir = new VDFSDirectoryInfo(path);
                if (parent != null)
                {
                    parent.SubDirectories.Add(dir);
                }
                vDirs.Add(path, dir);
            }

            List <Entry> directories = new List <Entry>(1);
            Entry        entry;

            do
            {
                entry = new Entry(br);
                if (entry.IsDirectory)
                {
                    directories.Add(entry);
                }
                else
                {
                    AddFile(dir, entry);
                }
            } while (!entry.IsLastEntry);

            for (int i = 0; i < directories.Count; i++)
            {
                ReadEntry(br, directories[i].Name, dir);
            }
        }
Beispiel #3
0
 public VDFSFileInfo(string path, VDFSDirectoryInfo dirInfo, VDFSArchive archive, uint offset, uint size)
 {
     this.path    = path;
     this.dirInfo = dirInfo;
     SetSource(archive, offset, size);
 }