예제 #1
0
        private bool CheckFormat(SevenZipArchiver pArchiver,
                                 List <ArchiveFileInfo> pArchiveEntryList, out bool pHasMeshes,
                                 out bool pHasData, out List <string> pDemoMovies, out List <string> pStockAssets,
                                 out AddonSignatureFile pAddonSignature)
        {
            List <string> fileNames = new List <string>();

            pHasMeshes = false;
            List <string> movies = new List <string>();
            List <string> stocks = new List <string>();

            pHasData        = false;
            pAddonSignature = null;

            foreach (ArchiveFileInfo entry in pArchiveEntryList)
            {
                string lwrName;
                fileNames.Add(lwrName = entry.FileName?.Trim().ToLower());
                if (!pHasData)
                {
                    if (lwrName?.StartsWith(@"data\") ?? false)
                    {
                        pHasData = true;
                    }
                }

                if (lwrName?.StartsWith(@"movies\") ?? false)
                {
                    string movieName = GetSubitemName(entry.FileName, "movies");
                    if (!string.IsNullOrEmpty(movieName) && !movies.Contains(movieName))
                    {
                        movies.Add(movieName);
                    }
                }

                if (lwrName?.StartsWith(@"stock\") ?? false)
                {
                    string stockName = GetSubitemName(entry.FileName, "stock");
                    if (!string.IsNullOrEmpty(stockName) && !stocks.Contains(stockName))
                    {
                        stocks.Add(stockName);
                    }
                }
            }

            pDemoMovies  = movies.Count > 0 ? movies : null;
            pStockAssets = stocks.Count > 0 ? stocks : null;

            pHasMeshes = fileNames.Contains("meshdata.data") && fileNames.Contains("meshdata.index");

            bool formatOk = fileNames.Contains(".addon") && fileNames.Contains("assetdata.jar");

            byte[] addonContent = pArchiver.ExtractArchivedFileToByte(".addon");
            if (addonContent != null)
            {
                pAddonSignature = AddonSignatureFile.Load(addonContent);
            }

            return(formatOk && (pAddonSignature != null));
        }
예제 #2
0
        private void CheckContents(out bool pHasMeshes, out bool pHasDemoMovies, out bool pHasStockAssets, out AddonSignatureFile pAddonSignature)
        {
            pAddonSignature = null;
            byte[] addonContent = File.ReadAllBytes(Path.Combine(AbsolutePath, ".addon"));
            if (addonContent != null)
            {
                pAddonSignature = AddonSignatureFile.Load(addonContent);
            }

            pHasMeshes = File.Exists(Path.Combine(AbsolutePath, "meshdata.data")) &&
                         File.Exists(Path.Combine(AbsolutePath, "meshdata.index"));

            pHasDemoMovies  = Directory.Exists(Path.Combine(AbsolutePath, "movies"));
            pHasStockAssets = Directory.Exists(Path.Combine(AbsolutePath, "stock"));
        }