public override bool Close()
 {
     if (m_rbf != null)
         m_rbf.Close();
     m_rbf = null;
     return true;
 }
 public override bool Close()
 {
     if (m_rbf != null)
     {
         m_rbf.Close();
     }
     m_rbf = null;
     return(true);
 }
Exemple #3
0
        private void Visit(FSNodeDir startDir)
        {
            if (m_stopSearch.WaitOne(0))
            {
                return;
            }

            foreach (FSNodeFile file in startDir.Files)
            {
                if (m_stopSearch.WaitOne(0))
                {
                    return;
                }
                if (file.Name.EndsWith(".rbf"))
                {
                    UniFile         uni = file.GetUniFile();
                    RelicBinaryFile rbf;
                    try
                    {
                        rbf = new RelicBinaryFile(uni)
                        {
                            KeyProvider    = ModManager.RBFKeyProvider,
                            UseKeyProvider = RBFSettings.UseKeyProviderForLoading
                        };
                        rbf.ReadData();
                    }
                    catch (Exception ex)
                    {
                        if (OnFileOpenFailed != null)
                        {
                            OnFileOpenFailed(ex);
                        }
                        if (m_advanceProgressCallback != null)
                        {
                            m_advanceProgressCallback.Invoke();
                        }
                        continue;
                    }

                    m_foreachRBF.Invoke(rbf.AttributeStructure, file.PathInTree);
                }
                if (m_advanceProgressCallback != null)
                {
                    m_advanceProgressCallback.Invoke();
                }
            }

            foreach (FSNodeDir dir in startDir.Directories)
            {
                if (m_stopSearch.WaitOne(0))
                {
                    return;
                }
                Visit(dir);
            }
        }
 /// <exception cref="CopeDoW2Exception">Failed to load file as RBF! Visit the options and ensure that the settings correspond to the game version you're trying to modify.</exception>
 protected void LoadFile(UniFile file)
 {
     if (file.FileExtension == "rbf")
     {
         m_rbf = new RelicBinaryFile(file)
         {
             KeyProvider    = ModManager.RBFKeyProvider,
             UseKeyProvider = RBFSettings.UseKeyProviderForLoading
         };
         try
         {
             m_rbf.ReadData();
         }
         catch (Exception ex)
         {
             throw new CopeDoW2Exception(ex,
                                         "Failed to load file as RBF! Visit the plugin's options " +
                                         "and ensure that the settings correspond to " +
                                         "the game version you're trying to modify.");
         }
     }
     else if (file.FileExtension == "attr_pc")
     {
         try
         {
             var attribStruct = BAFReader.Read(file.Stream);
             file.Close();
             m_rbf = new RelicBinaryFile(attribStruct)
             {
                 FilePath = file.FilePath, UseKeyProvider = false
             };
         }
         catch (Exception ex)
         {
             throw new CopeDoW2Exception(ex, "Failed to load file as attr_pc!");
         }
     }
     file.Close();
     m_rbfEditorCore.Analyze(m_rbf.AttributeStructure.Root);
 }
 /// <exception cref="CopeDoW2Exception">Failed to load file as RBF! Visit the options and ensure that the settings correspond to the game version you're trying to modify.</exception>
 protected void LoadFile(UniFile file)
 {
     if (file.FileExtension == "rbf")
     {
         m_rbf = new RelicBinaryFile(file)
                     {
                         KeyProvider = ModManager.RBFKeyProvider,
                         UseKeyProvider = RBFSettings.UseKeyProviderForLoading
                     };
         try
         {
             m_rbf.ReadData();
         }
         catch (Exception ex)
         {
             throw new CopeDoW2Exception(ex,
                                         "Failed to load file as RBF! Visit the plugin's options " +
                                         "and ensure that the settings correspond to " +
                                         "the game version you're trying to modify.");
         }
     }
     else if (file.FileExtension == "attr_pc")
     {
         try
         {
             var attribStruct = BAFReader.Read(file.Stream);
             file.Close();
             m_rbf = new RelicBinaryFile(attribStruct) {FilePath = file.FilePath, UseKeyProvider = false};
         }
         catch (Exception ex)
         {
             throw new CopeDoW2Exception(ex, "Failed to load file as attr_pc!");
         }
     }
     file.Close();
     m_rbfEditorCore.Analyze(m_rbf.AttributeStructure.Root);
 }
        private void Visit(FSNodeDir startDir)
        {
            if (m_stopSearch.WaitOne(0))
                return;

            foreach (FSNodeFile file in startDir.Files)
            {
                if (m_stopSearch.WaitOne(0))
                    return;
                if (file.Name.EndsWith(".rbf"))
                {
                    UniFile uni = file.GetUniFile();
                    RelicBinaryFile rbf;
                    try
                    {
                        rbf = new RelicBinaryFile(uni)
                        {
                            KeyProvider = ModManager.RBFKeyProvider,
                            UseKeyProvider = RBFSettings.UseKeyProviderForLoading
                        };
                        rbf.ReadData();
                    }
                    catch (Exception ex)
                    {
                        if (OnFileOpenFailed != null)
                            OnFileOpenFailed(ex);
                        if (m_advanceProgressCallback != null)
                            m_advanceProgressCallback.Invoke();
                        continue;
                    }

                    m_foreachRBF.Invoke(rbf.AttributeStructure, file.PathInTree);
                }
                if (m_advanceProgressCallback != null)
                    m_advanceProgressCallback.Invoke();
            }

            foreach (FSNodeDir dir in startDir.Directories)
            {
                if (m_stopSearch.WaitOne(0))
                    return;
                Visit(dir);
            }
        }