Ejemplo n.º 1
0
        void DeleteCharacterFile(uint inst, uint guid, SimPe.Interfaces.Files.IPackageFile pkg, SimPe.PackedFiles.Wrapper.ExtSDesc victim)
        {
            //do not delete for NPCs
            if (victim.IsNPC)
            {
                return;
            }

            if (System.IO.File.Exists(victim.CharacterFileName))
            {
                if (Message.Show("SimPE can now delete the Character File \"" + victim.CharacterFileName + "\" from your System. \n\nShould SimPE delete this File?", "Question", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                try
                {
                    SimPe.Packages.StreamItem si = SimPe.Packages.StreamFactory.UseStream(victim.CharacterFileName, System.IO.FileAccess.Read);
                    si.Close();

                    System.IO.File.Delete(victim.CharacterFileName);

                    /*FileTable.ProviderRegistry.SimNameProvider.BaseFolder = null;
                     * FileTable.ProviderRegistry.SimNameProvider.BaseFolder = System.IO.Path.GetDirectoryName(pkg.SaveFileName);*/
                }
                catch (Exception ex)
                {
                    Helper.ExceptionMessage(ex);
                }
            }
        }
Ejemplo n.º 2
0
        public void Setup(string pkgname)
        {
            if (pkgname == null)
            {
                pkgname = "";
            }

            this.tbPkg.Text = pkgname;
            tbs.HeaderText  = System.IO.Path.GetFileNameWithoutExtension(pkgname);

            si = null;
            pr = null;
            pg.SelectedObject = null;
            llOpen.Enabled    = false;
            try
            {
                if (System.IO.File.Exists(pkgname))
                {
                    si = SimPe.Packages.StreamFactory.UseStream(pkgname, System.IO.FileAccess.ReadWrite, false);
                }

                if (!si.FileStream.CanWrite || !si.FileStream.CanRead)
                {
                    si = null;
                }

                if (si != null)
                {
                    pr = new SimPe.Packages.PackageRepair(SimPe.Packages.GeneratableFile.LoadFromFile(pkgname));

                    pg.SelectedObject = pr.IndexDetailsAdvanced;
                    llOpen.Enabled    = (pr.Package != null);
                }
            }
            catch {}

            llRepair.Enabled = (si != null);
        }