コード例 #1
0
        internal static Patch GetLicensesPatch(ISystemOperations so, ISession session, string evfPath)
        {
            var folderLicensesPath = so.PathCombine(session.FolderPath, "LicenseKeys.bin");
            var fileLicensesPath   = so.PathCombine(evfPath, "LicenseKeys.bin");
            var folderHasLicenses  = so.FileExists(folderLicensesPath);
            var fileHasLicenses    = so.FileExists(fileLicensesPath);

            if (folderHasLicenses && fileHasLicenses)
            {
                if (session.Action == ActionType.Extract)
                {
                    return(Patch.MakeLicensesChange(so.FileReadAllBytes(folderLicensesPath), so.FileReadAllBytes(fileLicensesPath)));
                }
                else
                {
                    return(Patch.MakeLicensesChange(so.FileReadAllBytes(fileLicensesPath), so.FileReadAllBytes(folderLicensesPath)));
                }
            }
            else if (!folderHasLicenses && !fileHasLicenses)
            {
                return(null);
            }
            else if (session.Action == ActionType.Extract ? !folderHasLicenses : !fileHasLicenses)
            {
                return(Patch.MakeLicensesChange(new byte[0], so.FileReadAllBytes(session.Action == ActionType.Extract ? fileLicensesPath : folderLicensesPath)));
            }
            else
            {
                return(Patch.MakeLicensesChange(so.FileReadAllBytes(session.Action == ActionType.Extract ? folderLicensesPath : fileLicensesPath), new byte[0]));
            }
        }
コード例 #2
0
 internal static bool FrxFilesAreDifferent(ISystemOperations so, string frxPath1, string frxPath2, out string explain)
 {
     try
     {
         var frxBytes1 = so.FileReadAllBytes(frxPath1);
         var frxBytes2 = so.FileReadAllBytes(frxPath2);
         using (var frxCfStream1 = new MemoryStream(frxBytes1, 24, frxBytes1.Length - 24, false))
             using (var frxCfStream2 = new MemoryStream(frxBytes2, 24, frxBytes2.Length - 24, false))
                 using (var cf1 = new CompoundFile(frxCfStream1))
                     using (var cf2 = new CompoundFile(frxCfStream2))
                     {
                         return(CfStoragesAreDifferent(cf1.RootStorage, cf2.RootStorage, out explain));
                     }
     }
     catch (Exception ex)
     {
         explain = ex.Message;
         return(true);
     }
 }