Example #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);
            }
        }
Example #2
0
 public VDFSFileHandle(VDFSFileInfo info)
 {
     this.info = info;
 }
Example #3
0
        static void VDFS_SearchFile(RegisterMemory mem)
        {
            try
            {
                zFile_File zfile    = new zFile_File(mem.ECX);
                string     fileName = new zString(mem.GetArg(0)).ToString();
                string     folder   = new zString(mem.GetArg(1)).ToString();

                if (folder.Length > 0 && folder[0] == '\\')
                {
                    folder = folder.Substring(1);
                }
                if (folder.Length > 0 && folder[folder.Length - 1] == '\\')
                {
                    folder = folder.Remove(folder.Length - 1);
                }

                //Logger.Log("SearchFile: " + fileName + " " + folder);
                if (vFiles.Count > 0)
                {
                    if (vDirs.TryGetValue(folder, out VDFSDirectoryInfo dir))
                    {
                        VDFSFileInfo fi = dir.SearchFile(fileName);
                        if (fi != null)
                        {
                            zfile.SetPath('\\' + fi.Path);
                            mem.EAX = 0;
                            return;
                        }
                    }
                }

                DirectoryInfo dirInfo = new DirectoryInfo(Program.ProjectPathCombine(folder));
                if (dirInfo.Exists)
                {
                    FileInfo fi = dirInfo.EnumerateFiles(fileName, SearchOption.AllDirectories).FirstOrDefault();
                    if (fi != null)
                    {
                        zfile.SetPath(fi.FullName.Substring(Program.ProjectPath.Length));
                        mem.EAX = 0;
                        return;
                    }
                }

                dirInfo = new DirectoryInfo(Program.GothicRootPathCombine(folder));
                if (dirInfo.Exists)
                {
                    FileInfo fi = dirInfo.EnumerateFiles(fileName, SearchOption.AllDirectories).FirstOrDefault();
                    if (fi != null)
                    {
                        zfile.SetPath(fi.FullName.Substring(Program.GothicRootPath.Length));
                        mem.EAX = 0;
                        return;
                    }
                }

                mem.EAX = 0x138B;
                //Logger.Log("SearchFile: " + fileName + " not found!");
            }
            catch (Exception e)
            {
                Logger.LogError(e.ToString());
            }
        }