public static void DeleteFile(FileType fileType) { if (fileType == FileType.Account) { FileIOHelper.DeleteAccountFileOnApplieDevice(); } }
private static void SetAccountContent(string content) { if (GlobalManager.ClientType == 2) { FileIOHelper.PutAccountContentToAppleDevice(content); } }
public static void WriteFile(FileType fileType, string content) { switch (fileType) { case FileType.Account: FileIOHelper.SetAccountContent(content); break; case FileType.DropCache: FileIOHelper.SetDropCache(content); break; case FileType.Duration: FileIOHelper.SetDuration(content); break; case FileType.SerializeError: FileIOHelper.SetSerializeError(content); break; case FileType.SuspendError: FileIOHelper.SetSuspendError(content); break; } }
private static void DeleteAccountFileOnApplieDevice() { if (GlobalManager.ClientType == 2) { string accountFilePath = FileIOHelper.GetAccountFilePath(); Log.debug("@@@@ DeleteAccountFileOnApplieDevice"); if (File.Exists(accountFilePath)) { Log.debug("@@@ begin to delete file!"); File.Delete(accountFilePath); } } }
private static string GetAccountContent() { string result; if (GlobalManager.ClientType == 2) { result = FileIOHelper.GetAccountContentFromAppleDevice(); } else { result = null; } return(result); }
private static void PutAccountContentToAppleDevice(string content) { if (GlobalManager.ClientType == 2) { string accountFilePath = FileIOHelper.GetAccountFilePath(); if (File.Exists(accountFilePath)) { File.Delete(accountFilePath); } FileStream fileStream = new FileStream(accountFilePath, FileMode.Create); byte[] bytes = new UTF8Encoding(true).GetBytes(content); fileStream.Write(bytes, 0, bytes.Length); fileStream.Close(); } }
private static string GetAccountContentFromAppleDevice() { string text = string.Empty; string result; if (GlobalManager.ClientType == 2) { string accountFilePath = FileIOHelper.GetAccountFilePath(); if (!File.Exists(accountFilePath)) { result = text; return(result); } FileStream fileStream = new FileStream(accountFilePath, FileMode.OpenOrCreate, FileAccess.Read); BinaryReader binaryReader = new BinaryReader(fileStream); int num = (int)fileStream.Length; byte[] array = new byte[num]; binaryReader.Read(array, 0, array.Length); text = Encoding.Default.GetString(array); fileStream.Close(); } result = text; return(result); }
public static string ReadFile(FileType fileType) { string result; switch (fileType) { case FileType.Account: result = FileIOHelper.GetAccountContent(); break; case FileType.DropCache: result = FileIOHelper.GetDropCache(); break; case FileType.Duration: result = FileIOHelper.GetDuration(); break; default: result = string.Empty; break; } return(result); }