Ejemplo n.º 1
0
 public bool saveFile(string path, string savePath)
 {
     foreach (BarEntry entry in barEntries)
     {
         if (entry.fileName == path)
         {
             BarReader r = new BarReader(entry.barFilePath);
             r.saveFile(entry, savePath);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// <para>This constructor is used solely for extracting XML 
 /// data from a BAR file without leaving the XMB file sitting 
 /// around on the hard disk.</para>
 /// 
 /// <para>The method works by saving the file in its native
 /// XMB form, and then setting the class attributes to focus
 /// on extracting that file. Then the saveXMB method will
 /// extract from this temporary file, and once this class is
 /// disposed of and the destructor is called the temporary
 /// file will be deleted.</para>
 /// </summary>
 /// <param name="entry">The BAR file entry to be saved to XML.</param>
 /// <param name="saveDirectory">The directory to save the new XML 
 /// file to (leave blank for the same directory as the program).</param>
 public XMBReader(BarEntry entry, string saveDirectory)
 {
     // Set up instance variables...
     xmbFilePath = entry.fileName + ".tmp";
     xmlFilePath = saveDirectory + "\\" + entry.fileName.Substring(0, entry.fileName.LastIndexOf('.'));
     fileLength = 0;
     // Create a BarReader and save the file we need
     // to the temporary destination (as the XMB file)
     BarReader reader = new BarReader(entry.barFilePath);
     reader.saveFile(entry,xmbFilePath);
     // Set the temporary file flag
     isTemporaryFile = true;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads all BAR files within the game directory as
        /// specified by the constructor and indexes the files
        /// within them. Returns a bool value indicating whether
        /// the operation has been successful.
        /// </summary>
        /// <returns>True if the load operation has been
        /// successful, otherwise false.</returns>
        public bool load()
        {
            // There is a danger of an exception being thrown
            // so we'd best try to catch them...
            try
            {
                // Check path exists...
                DirectoryInfo dir = new DirectoryInfo(gamePath);
                if (!dir.Exists)
                    throw new Exception("Directory doesn't exist.");
                // Get a list of all BAR files in the
                // game directory
                FileInfo[] allBarFiles = dir.GetFiles("*.bar", SearchOption.AllDirectories);
                foreach (FileInfo f in allBarFiles)
                {
                    BarReader r = new BarReader(f.FullName);
                    // We can only load the entries if the
                    // BAR file has loaded successfully, so
                    // load it and check the return value
                    if (r.load())
                    {
                        foreach (BarEntry e in r.files)
                        {

                            barEntries.Add(e);
                        }
                    }
                }
                // If we've got here successfully we've
                // loaded all possible values so return
                // true...
                return true;
            }
            catch (Exception e)
            {
                // Something went wrong, return false.
                return false;
            }
        }