Example #1
0
        /// <summary>
        /// Build the initial cache of BankInfo items.
        /// Each BankInfo will associate the bank name (eg. MyBank.SC2Bank) to
        /// one particular file.  The reason is that different versions of the same
        /// old copies of the same bank (with the same file-name) lying around.  Since I'm not
        /// sure how to get the author-number from the MPQ file, we have to make a guesstimate
        /// as to which bank is the correct one.  I take the one most recently modified.
        /// </summary>
        public void InitializeCache()
        {
            DirectoryInfo bankFolder = new DirectoryInfo(BANKS_FOLDER);

            if (!bankFolder.Exists)
            {
                return;
            }
            IEnumerable <FileInfo> bankFiles = bankFolder.GetFiles("*.SC2Bank", SearchOption.AllDirectories);
            int numBanksTotal     = bankFiles.Count();
            int numBanksProcessed = 0;

            foreach (FileInfo file in bankFiles)
            {
                //Ignore bank files that are not in the correct folders
                if (BankPathParser.IsValidBankPath(file.FullName))
                {
                    //Add the new bank to the cache
                    _bankCache.GetOrAddBankInfo(file.FullName);
                }
                numBanksProcessed++;
                OnProgressChanged((double)numBanksProcessed / numBanksTotal);
            }
        }
Example #2
0
        public BankInfo GetOrAddBankInfo(string bankPath)
        {
            BankPathParser bankPathParser = new BankPathParser(bankPath);

            return(GetOrAddBankInfo(bankPath, bankPathParser.PlayerNumber, bankPathParser.AuthorNumber));
        }