Пример #1
0
        private void ExtractFileContents()
        {
            string filename = mSaveFileNameTextBox.Text;
            int    result   = ARMaxNativeMethods.InitMaxSave();

            if (result != 0)
            {
                throw new Exception("Could not load initialize ARMax DLL!");
            }
            result = ARMaxNativeMethods.LoadSave(filename);
            if (result != 0)
            {
                throw new Exception("Could not load file:" + filename);
            }

            StringBuilder rootDirName = new StringBuilder(256);

            ARMaxNativeMethods.GetRootDir(rootDirName, 256);
            rootDirName.Append("\\");
            string dirName = ".\\UnpackFolder_" + rootDirName.ToString();

            if (Directory.Exists(dirName))
            {
                Directory.Delete(dirName, true);
            }
            Directory.CreateDirectory(dirName);

            int numFiles = ARMaxNativeMethods.NumberOfFiles();

            // show the files in the list box
            for (int i = 1; i < numFiles + 1; i++) // there is no '0'th file
            {
                try
                {
                    result = ARMaxNativeMethods.ExtractAFile(i, dirName);
                    if (result != 0)
                    {
                        Console.Error.Write("'ARMaxNativeMethods.ExtractAFile' Failed; code = {0}", result);
                    }
                }
                catch (Exception exc)
                {
                    Console.Error.WriteLine("Error calling 'ARMaxNativeMethods.GetRootDir()' LastError:{0}\n{1}",
                                            System.Runtime.InteropServices.Marshal.GetLastWin32Error()
                                            , exc.Message
                                            );
                }
            }
            ARMaxNativeMethods.FreeMaxSave();
        }
Пример #2
0
        private void ShowContants(string filename)
        {
            if (filename.EndsWith(".max", StringComparison.InvariantCultureIgnoreCase))
            {
                mInternalFilesListBox.Items.Clear();
                int result = LoadARMaxFile(filename);

                int           numFiles = ARMaxNativeMethods.NumberOfFiles();
                StringBuilder buff     = new StringBuilder(256);
                int           fileSize = -1;
                // show the files in the list box
                for (int i = 1; i < numFiles + 1; i++) // there is no '0'th file
                {
                    try
                    {
                        result = ARMaxNativeMethods.FileDetails(i, buff, 256, ref fileSize);
                        if (result == 0)
                        {
                            mInternalFilesListBox.Items.Add(buff.ToString()); // add to the list box items
                        }
                        else
                        {
                            Console.Error.WriteLine("Error Code = {0}", result);
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.Error.WriteLine("Error calling 'ARMaxNativeMethods.GetRootDir()' LastError:{0}\n{1}",
                                                System.Runtime.InteropServices.Marshal.GetLastWin32Error()
                                                , exc.Message
                                                );
                    }
                    buff.Length = 0; // clear out the chars in buff
                }
                ARMaxNativeMethods.FreeMaxSave();
                mExtractButton.Enabled = true;
            }
            else
            {
                MessageBox.Show("This is not a a .max file: " + filename);
            }
        }
Пример #3
0
        public PS2FileHelper(string filename)
        {
            this.Filename = filename;

            int result = ARMaxNativeMethods.InitMaxSave();

            if (result == 0)
            {
                result = ARMaxNativeMethods.LoadSave(filename);

                Console.WriteLine("#ARMax version: {0}, Number of files:{1}; RootDir: {2}",
                                  ARMaxNativeMethods.DLLVersion(),
                                  ARMaxNativeMethods.NumberOfFiles()
                                  , this.RootDir
                                  );
            }
            else
            {
                Console.Error.WriteLine("#Error calling 'ARMaxNativeMethods.InitMaxSave()' result:{0}", result);
            }
        }
Пример #4
0
        public void ExtractPS2SaveContents(string pathToExtractTo)
        {
            string dirName = pathToExtractTo;

            if (!dirName.EndsWith("\\"))
            {
                dirName += "\\";
            }

            if (Directory.Exists(dirName))
            {
                Directory.Delete(dirName, true);
            }
            Directory.CreateDirectory(dirName);
            int result   = -1;
            int numFiles = ARMaxNativeMethods.NumberOfFiles();

            // show the files in the list box
            for (int i = 1; i <= numFiles; i++) // there is no '0'th file
            {
                try
                {
                    result = ARMaxNativeMethods.ExtractAFile(i, dirName);
                    if (result != 0)
                    {
                        Console.Error.Write("'ARMaxNativeMethods.ExtractAFile' Failed; code = {0}", result);
                    }
                }
                catch (Exception exc)
                {
                    Console.Error.WriteLine("Error calling 'ARMaxNativeMethods.GetRootDir()' LastError:{0}\n{1}",
                                            System.Runtime.InteropServices.Marshal.GetLastWin32Error()
                                            , exc.Message
                                            );
                }
            }
        }