123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.IO;
- using UnityEngine;
- public class FileHackGlobalGameManagers
- {
- public static string Path
- {
- get
- {
- return Application.dataPath + "/globalgamemanagers";
- }
- }
- public static byte[] ReadAllBytes(string path = "")
- {
- if (string.IsNullOrEmpty(path))
- {
- path = FileHackGlobalGameManagers.Path;
- }
- byte[] result = null;
- try
- {
- result = File.ReadAllBytes(path);
- }
- catch (Exception ex)
- {
- Debug.LogError(ex.Message);
- }
- return result;
- }
- public static bool WriteAllBytes(byte[] src, string path = "")
- {
- if (string.IsNullOrEmpty(path))
- {
- path = FileHackGlobalGameManagers.Path;
- }
- bool result = false;
- try
- {
- File.WriteAllBytes(path, src);
- result = true;
- }
- catch (Exception ex)
- {
- Debug.LogError(ex.Message);
- }
- return result;
- }
- public static int IndexOfVRFlag(byte[] src)
- {
- if (src == null || src.Length <= 0)
- {
- return -1;
- }
- string text = "com.";
- string text2 = "1.0";
- int num = FileHackGlobalGameManagers.IndexOf(src, 0, text);
- if (num <= 0)
- {
- return -1;
- }
- int num2 = FileHackGlobalGameManagers.IndexOf(src, num, text2);
- if (num2 <= 0)
- {
- return -1;
- }
- int num3 = num2 + text2.Length + 9;
- return (num3 >= src.Length) ? -1 : num3;
- }
- public static int IndexOf(byte[] src, int offset, string text)
- {
- byte[] array = new byte[text.Length];
- for (int i = 0; i < text.Length; i++)
- {
- array[i] = (byte)text[i];
- }
- int num = 0;
- while (num + offset < src.Length)
- {
- if (src[num + offset] == array[0])
- {
- int num2 = num + offset;
- int num3 = 0;
- while (num2 < src.Length && num3 < array.Length)
- {
- if ((char)src[num2] != text[num3])
- {
- num3 = -1;
- break;
- }
- num2++;
- num3++;
- }
- if (0 < num3)
- {
- return num + offset;
- }
- }
- num++;
- }
- return -1;
- }
- }
|