public Ps3SaveManager(string savedir, byte[] securefileid)
        {
            if (!Directory.Exists(savedir))
            {
                throw new Exception("No such directory exist!");
            }
            if (!File.Exists(Path.Combine(savedir, "PARAM.PFD")))
            {
                throw new Exception("Rootdirectory does not contain any PARAM.PFD, Please load a valid directory");
            }
            if (!File.Exists(Path.Combine(savedir, "PARAM.SFO")))
            {
                throw new Exception("Rootdirectory does not contain any PARAM.SFO, Please load a valid directory");
            }
            Param_PFD = new Param_PFD(Path.Combine(savedir, "PARAM.PFD"));
            Param_SFO = new PARAM_SFO(Path.Combine(savedir, "PARAM.SFO"));
            if (securefileid != null)
            {
                Param_PFD.SecureFileID = securefileid;
            }
            RootPath = savedir;
            if (File.Exists(Path.Combine(savedir, "ICON0.PNG")))
            {
                //prevent file lock,reading to memory instead.
                SaveImage = Image.FromStream(new MemoryStream(File.ReadAllBytes(Path.Combine(savedir, "ICON0.PNG"))));
            }

            Files = (from ent in Param_PFD.Entries
                     let x = new FileInfo(Path.Combine(savedir, ent.file_name))
                             where x.Extension.ToUpper() != ".PFD" && x.Extension.ToUpper() != ".SFO"
                             select new Ps3File(Path.Combine(savedir, ent.file_name), ent, this)).ToArray();
        }
 public int DecryptAllFiles()
 {
     try
     {
         if (Param_PFD == null || !Directory.Exists(RootPath))
         {
             return(-1);
         }
         return(Param_PFD.DecryptAllFiles(RootPath));
     }
     catch
     {
         return(-1);
     }
 }
 public int EncryptAllFiles()
 {
     try
     {
         if (Param_PFD == null || !Directory.Exists(RootPath))
         {
             return(-1);
         }
         var x = Param_PFD.EncryptAllFiles(RootPath);
         if (x > 0)
         {
             if (Param_PFD.RebuilParamPFD(RootPath, false))
             {
                 return(x);
             }
         }
         return(-1);
     }
     catch
     {
         return(-1);
     }
 }
 public bool ReBuildChanges(bool encryptfiles)
 {
     return(Param_PFD.RebuilParamPFD(RootPath, encryptfiles));
 }
 public bool ReBuildChanges()
 {
     return(Param_PFD.RebuilParamPFD(RootPath, false));
 }