private static void StoreStateToDrive(LocalStorageFileState state)
 {
     try
     {
         LocalStorageAPI.s_log.LogDebug("StoreState State={0}", new object[] { state });
         string str = LocalStorageAPI.MakeFullPathFromState(state);
         LocalStorageAPI.s_log.LogDebug("Attempting to save {0}", new object[] { str });
         if (!File.Exists(str))
         {
             FileStream fileStream = File.Create(str, (int)state.FileData.Length);
             if (state.CompressedData != null)
             {
                 LocalStorageAPI.s_log.LogDebug("Writing compressed file to disk");
                 fileStream.Write(state.CompressedData, 0, (int)state.CompressedData.Length);
             }
             else
             {
                 LocalStorageAPI.s_log.LogDebug("Writing uncompressed file to disk");
                 fileStream.Write(state.FileData, 0, (int)state.FileData.Length);
             }
             fileStream.Flush();
             fileStream.Close();
             LocalStorageAPI.s_log.LogDebug("Writing completed");
         }
         else
         {
             LocalStorageAPI.s_log.LogDebug("Unable to save the file, it already exists");
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         LocalStorageAPI.s_log.LogWarning("EXCEPTION (StoreStateToDrive): {0}", new object[] { exception.Message });
     }
 }
 private bool LoadStateFromDrive(LocalStorageFileState state)
 {
     try
     {
         LocalStorageAPI.s_log.LogDebug("LoadState State={0}", new object[]
         {
             state
         });
         string text = LocalStorageAPI.MakeFullPathFromState(state);
         LocalStorageAPI.s_log.LogDebug("Attempting to load {0}", new object[]
         {
             text
         });
         if (!File.Exists(text))
         {
             LocalStorageAPI.s_log.LogDebug("File does not exist, unable to load from disk.");
             bool result = false;
             return(result);
         }
         FileStream fileStream = File.OpenRead(text);
         byte[]     array      = new byte[fileStream.get_Length()];
         fileStream.Read(array, 0, array.Length);
         fileStream.Close();
         if (LocalStorageAPI.ComputeSHA256(array) != state.CH.Sha256Digest)
         {
             LocalStorageAPI.s_log.LogDebug("File was loaded but integrity check failed, attempting to delete ...");
             File.Delete(text);
             bool result = false;
             return(result);
         }
         LocalStorageAPI.DecompressStateIfPossible(state, array);
         LocalStorageAPI.s_log.LogDebug("Loading completed");
         LocalStorageAPI.FinalizeState(state);
     }
     catch (Exception ex)
     {
         LocalStorageAPI.s_log.LogWarning("EXCEPTION: {0}", new object[]
         {
             ex.get_Message()
         });
         bool result = false;
         return(result);
     }
     return(true);
 }
        private bool LoadStateFromDrive(LocalStorageFileState state)
        {
            bool flag;

            try
            {
                LocalStorageAPI.s_log.LogDebug("LoadState State={0}", new object[] { state });
                string str = LocalStorageAPI.MakeFullPathFromState(state);
                LocalStorageAPI.s_log.LogDebug("Attempting to load {0}", new object[] { str });
                if (File.Exists(str))
                {
                    FileStream fileStream = File.OpenRead(str);
                    byte[]     numArray   = new byte[checked ((IntPtr)fileStream.Length)];
                    fileStream.Read(numArray, 0, (int)numArray.Length);
                    fileStream.Close();
                    if (LocalStorageAPI.ComputeSHA256(numArray) == state.CH.Sha256Digest)
                    {
                        LocalStorageAPI.DecompressStateIfPossible(state, numArray);
                        LocalStorageAPI.s_log.LogDebug("Loading completed");
                        LocalStorageAPI.FinalizeState(state);
                        return(true);
                    }
                    else
                    {
                        LocalStorageAPI.s_log.LogDebug("File was loaded but integrity check failed, attempting to delete ...");
                        File.Delete(str);
                        flag = false;
                    }
                }
                else
                {
                    LocalStorageAPI.s_log.LogDebug("File does not exist, unable to load from disk.");
                    flag = false;
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                LocalStorageAPI.s_log.LogWarning("EXCEPTION: {0}", new object[] { exception.Message });
                flag = false;
            }
            return(flag);
        }