www.pudn.com > boogiebot.zip > MPQManager.cs


using System; 
using System.IO; 
using System.Collections.Generic; 
using System.Text; 
 
namespace BoogieBot.Common 
{ 
    /// Manages all opened MPQ Archives and allows easy access to files. 
    public class MPQManager 
    { 
        /// Creates MPQManager object. 
        /// Full path to World of Warcraft game folder. 
        public MPQManager(String wowpath) 
        { 
        } 
 
        /// Searches for specified file in all opened MPQ Archives, and returns an MPQFile object to access it. 
        /// Filename to search for in MPQs, and open 
        /// Include patch.mpq in search? 
        /*public MPQFile Open(String filename, Boolean usepatch) 
        { 
            foreach (MPQArchive mpqArchive in archiveList) 
            { 
                if (!usepatch & mpqArchive.Filename.Equals("patch.MPQ")) 
                { 
                    BoogieCore.Log(LogType.SystemDebug, "MPQManager: Skipping patch.MPQ"); 
                    continue; 
                } 
 
                try 
                { 
                    return mpqArchive.OpenFile(filename); 
                } 
                catch (FileNotFoundException) 
                { 
                    // This is normal here, ignore it. 
                    //BoogieCore.Log(LogType.SystemDebug, "MPQManager: {0} was not found in {1}.", filename, mpqArchive.Filename); 
                } 
                catch (Exception ex) 
                { 
                    BoogieCore.Log(LogType.System, "MPQManager: Caught exception in {0}: {1}.  (Ignoring and continuing)", mpqArchive.Filename, ex.Message); 
                } 
            } 
 
            BoogieCore.Log(LogType.System, "MPQManager: {0} was not found in ANY archives. Typo?", filename); 
            // If we got to here, the file wasn't found in any open MPQ archives. Throw exception :( 
            throw new FileNotFoundException("The file was not found.", filename); 
        }*/ 
 
        /*public List ArchiveList 
        { 
            get { return ArchiveList; } 
        }*/ 
 
        //private List archiveList = new List(); 
 
        // Probably shouldn't be hardcoded in, but stored in an .INI file?? 
        //private String[] mpqFileList = { "patch.MPQ", /*"expansion.MPQ",*/ "dbc.MPQ", "terrain.MPQ", "wmo.MPQ" }; 
    } 
} 
 
// List of all MPQs 
// "backup.MPQ", "base.MPQ", "dbc.MPQ", "expansion.MPQ", "expansionLoc.MPQ", "fonts.MPQ", "interface.MPQ", "misc.MPQ", "model.MPQ", "patch.MPQ", "sound.MPQ", "speech.MPQ", "terrain.MPQ", "texture.MPQ", "wmo.MPQ" };