Exemple #1
0
        public Package(string fileName, FolderEntry rootFolder)
        {
            this.RootFolder = rootFolder;

            this._fileName = fileName;
            this._packageStream = File.Open(this._fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
        }
Exemple #2
0
        public Package(string fileName, FolderEntry rootFolder)
        {
            this.RootFolder = rootFolder;

            this._fileName      = fileName;
            this._packageStream = File.Open(this._fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
        }
Exemple #3
0
        public static Package Open(string strPackPath)
        {
            Package pakPackage = null;

            if (strPackPath != null)
            {
                if (!File.Exists(strPackPath))
                {
                    strPackPath = null;
                }

                string strManifestPath = Path.ChangeExtension(strPackPath, ".PAK.MAN");

                if (strPackPath != null && !File.Exists(strManifestPath))
                {
                    MessageBox.Show("Unable to locate the coresponding\r\n" +
                                    "manifest for this package",
                                    "TL2MH",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    strManifestPath = null;
                }

                if (strPackPath != null && strManifestPath != null)
                {
                    List <PackageEntry> lstEntries = ReadManifest(strManifestPath);

                    Dictionary <string, FolderEntry> dctMap = new Dictionary <string, FolderEntry>();
                    FolderEntry feRoot =
                        new FolderEntry(Path.GetDirectoryName(lstEntries[0].Name), lstEntries[0]);
                    dctMap[lstEntries[0].Name] = feRoot;

                    for (int nCurrEntry = 1; nCurrEntry < lstEntries.Count; nCurrEntry++)
                    {
                        PackageEntry entCurr = lstEntries[nCurrEntry];

                        if (entCurr.Type == FileType.Directory)
                        {
                            FolderEntry feSubFolder = new FolderEntry(Path.GetDirectoryName(entCurr.Name), entCurr);

                            dctMap[entCurr.GroupName].SubFolders.Add(feSubFolder);

                            dctMap[entCurr.GroupName + entCurr.Name] = feSubFolder;
                        }
                        else
                        {
                            FileEntry feFile = new FileEntry(Path.GetFileName(entCurr.Name), entCurr);

                            dctMap[entCurr.GroupName].Files.Add(feFile);
                        }
                    }

                    pakPackage = new Package(strPackPath, feRoot);
                }
            }

            return(pakPackage);
        }
        public static Package Open(string strPackPath)
        {
            Package pakPackage = null;
            
            if (strPackPath != null)
            {
                if (!File.Exists(strPackPath))
                {
                    strPackPath = null;
                }

                string strManifestPath = Path.ChangeExtension(strPackPath, ".PAK.MAN");

                if (strPackPath != null && !File.Exists(strManifestPath))
                {
                    MessageBox.Show("Unable to locate the coresponding\r\n" + 
                                    "manifest for this package",
                                    "TL2MH",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    strManifestPath = null;
                }

                if (strPackPath != null && strManifestPath != null)
                {
                    List<PackageEntry> lstEntries = ReadManifest(strManifestPath);

                    Dictionary<string, FolderEntry> dctMap = new Dictionary<string, FolderEntry>();
                    FolderEntry feRoot =
                        new FolderEntry(Path.GetDirectoryName(lstEntries[0].Name), lstEntries[0]);
                    dctMap[lstEntries[0].Name] = feRoot;

                    for (int nCurrEntry = 1; nCurrEntry < lstEntries.Count; nCurrEntry++)
                    {
                        PackageEntry entCurr = lstEntries[nCurrEntry];

                        if (entCurr.Type == FileType.Directory)
                        {
                            FolderEntry feSubFolder = new FolderEntry(Path.GetDirectoryName(entCurr.Name), entCurr);

                            dctMap[entCurr.GroupName].SubFolders.Add(feSubFolder);

                            dctMap[entCurr.GroupName + entCurr.Name] = feSubFolder;
                        }
                        else
                        {
                            FileEntry feFile = new FileEntry(Path.GetFileName(entCurr.Name), entCurr);

                            dctMap[entCurr.GroupName].Files.Add(feFile);
                        }
                    }

                    pakPackage = new Package(strPackPath, feRoot);
                }
            }

            return pakPackage;
        }