예제 #1
0
        public void Load(string identifier)
        {
            m_fullPath = UnityEngine.Application.persistentDataPath + "/" + StringUtils.ToMD5(identifier);
            Log.i("读取信息:" + identifier + "        路径:" + m_fullPath);
            if (!File.Exists(m_fullPath))
            {
                return;
            }

            // Check file's MD5
            if (!FileUtil.GetFileMD5(m_fullPath).Equals(UnityEngine.PlayerPrefs.GetString(m_fullPath)))
            {
                File.Delete(m_fullPath);
                return;
            }

            //Read bytes to buffer
            FileStream fs = new FileStream(m_fullPath, FileMode.Open, FileAccess.Read);

            byte[] buffers = new byte[fs.Length];
            fs.Read(buffers, 0, buffers.Length);
            fs.Close();

            //Uncrypt and parse
            if (!string.IsNullOrEmpty(mFileCryptPassword))
            {
                Crypt.UnCrypt(buffers, mFileCryptPassword);
            }
            string content = Encoding.UTF8.GetString(buffers);

            m_dic = StringUtils.ReadDictionary(content);
            dirty = false;
        }
예제 #2
0
 public static byte[] readLuaFile(string path, bool encode = false)
 {
     if (!File.Exists(path))
     {
         Log.e("no such file: " + path);
         return(null);
     }
     byte[] bytes = File.ReadAllBytes(path);
     if (encode)
     {
         Crypt.UnCrypt(bytes, ENCODESTRING);
     }
     return(bytes);
 }
예제 #3
0
        public static byte[] readAssetLuaFile(string path, bool encode = false)
        {
            WWW www = new WWW(path);

            while (!www.isDone)
            {
                System.Threading.Thread.Sleep(10);                //比较hacker的做法
                continue;
            }

            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.LogError("no such file:" + path);
                return(null);
            }
            byte[] bytes = www.bytes;
            if (encode)
            {
                Crypt.UnCrypt(bytes, ENCODESTRING);
            }
            return(bytes);
        }