Exemple #1
0
        private void InitLua(string luaFilename, bool updatedScript)
        {
            luaState    = new LuaState();
            luaStateExt = new LuaStateExt(luaState);

            LuaDLL.open_luaext(luaState.L);
            LuaDLL.lua_settop(luaState.L, 0);

            byte [] scriptSource = null;
            if (updatedScript)
            {
                scriptSource = FileUtils.GetDataFromFile(luaFilename);
            }
            else
            {
                scriptSource = FileUtils.GetDataFromStreamingAssets(luaFilename);
            }

            object ret;
            var    ok = luaStateExt.doArc4Buffer(scriptSource, luaFilename, LBootApp.LUA_KEY, out ret);

            if (!ok)
            {
                LogUtil.Error("doArc4Buffer failed! " + luaFilename);
            }
        }
Exemple #2
0
 public static byte [] DecodeBundleFile(string path)
 {
     byte[] data = FileUtils.GetDataFromFile(path);
     if (data == null)
     {
         throw new Exception("DecodeBundleFile: cannot read file at " + path);
     }
     else
     {
         return(DecodeData(data, 0, data.Length));
     }
 }
Exemple #3
0
        public static Encoding GetEncodingOfFile(string filepath)
        {
#if MULTI_ENCODING
            LogUtil.Debug("GetEncodingOfFile: MULTI_ENCODING enabled");
            const long headerSize = 2;
            long       bytesRead  = 0;
            byte []    data       = FileUtils.GetDataFromFile(filepath, 0, headerSize, out bytesRead);
            if (bytesRead == headerSize)
            {
                return(GetEncodingOfData(data));
            }
            return(Encoding.Unknown);
#else
            return(Encoding.Unity);
#endif // MULTI_ENCODING
        }