public bool LoadLuaZip(string luaZipFileName)
        {
            if (string.IsNullOrEmpty(luaZipFileName))
            {
                Log.LogE("LoadLuaZip Error Arg!");
                return(false);
            }
            string filePath = FileUtil.CombinePath(JW.Res.FileUtil.GetIFSExtractPath(), luaZipFileName + ".bytes");

            if (!JW.Res.FileUtil.IsFileExist(filePath))
            {
                JW.Common.Log.LogE("LoadLuaZip Failed Not Exist File");
                return(false);
            }
            if (_curLuaZip != null)
            {
                _curLuaZip.Close();
                _curLuaZip = null;
            }
            _curLuaZip = new IFSFile();
            if (_curLuaZip.InitWithFile(filePath) == false)
            {
                JW.Common.Log.LogE("LuaZip Init Failed");
                return(false);
            }
            else
            {
                Log.LogD("<color=yellow>{0} LuaZip Init Successed!</color>", luaZipFileName);
                return(true);
            }
        }
 public void UnInit()
 {
     if (_curLuaZip != null)
     {
         _curLuaZip.Close();
         _curLuaZip = null;
     }
 }
 public void UnLoadLuaZip()
 {
     if (_curLuaZip != null)
     {
         _curLuaZip.Close();
         _curLuaZip = null;
     }
 }
 public void Dispose()
 {
     if (_www != null)
     {
         _www.Dispose();
         _www = null;
     }
     if (_downloadHandler != null)
     {
         _downloadHandler.Dispose();
         _downloadHandler = null;
     }
     _downloadBuffer  = null;
     _waitToDealBytes = null;
     _ifsFile         = null;
 }
 public bool Abort()
 {
     if (_www != null)
     {
         _www.Abort();
         _www.Dispose();
         _www = null;
     }
     if (_downloadHandler != null)
     {
         _downloadHandler.Dispose();
         _downloadHandler = null;
     }
     _downloadBuffer  = null;
     _waitToDealBytes = null;
     _ifsFile         = null;
     return(true);
 }
 //------------
 private void ReceiveContentLength(int contentLength)
 {
     JW.Common.Log.LogD("IFSDownloader ReceiveContentLength:{0:D} ", contentLength);
     //
     if (contentLength < 20)
     {
         JW.Common.Log.LogE("IFSDownloader Error ContentLength");
         _isError = true;
         Abort();
         return;
     }
     //
     _ifsFile            = new IFSFile();
     _waitToDealBytes    = new List <byte>(1024 * 1024);
     _dealState          = 0;
     _dealOffset         = 0;
     _entryNameLength    = 0;
     _dealEntryDataIndex = 0;
     _receivedLength     = 0;
     _totalLength        = contentLength;
 }
Exemplo n.º 7
0
        public static Boolean check_IFS(String rootDir)
        {
            String machine  = ConfigurationManager.AppSettings["as400Server"];
            String user     = ConfigurationManager.AppSettings["as400User"];
            String password = ConfigurationManager.AppSettings["as400Pwd"];

            AS400 server = new AS400();

            server.setSystemName(machine);
            server.setUserId(user);
            server.setPassword(password);
            IFSFile dir = new IFSFile(server, rootDir);

            if (dir.exists())
            {
                return(true);
            }



            return(false);
        }
        //----------------------lua文件包读取方式----------------
        public IEnumerator LoadMainLua(LuaEnv lua, System.Action <int> callback = null)
        {
            if (callback != null)
            {
                callback(LoadStateLoading);
            }
            //
            string filePath = FileUtil.CombinePath(JW.Res.FileUtil.GetIFSExtractPath(), "Main_Lua.bytes");

            if (!JW.Res.FileUtil.IsFileExist(filePath))
            {
                JW.Common.Log.LogE("Get Main_Lua.bytes pack File Failed");
                if (callback != null)
                {
                    callback(LoadStateFail);
                }
            }
            else
            {
                _curLuaZip = new IFSFile();
                if (_curLuaZip.InitWithFile(filePath) == false)
                {
                    JW.Common.Log.LogE("Get Main_Lua Init Failed");
                    if (callback != null)
                    {
                        callback(LoadStateFail);
                    }
                }
                else
                {
                    Log.LogD("<color=yellow>Init Main_Lua Done!</color>");
                    //
                    lua.AddLoader(CustomLuaLoader);
                    //启动
                    lua.DoString("require('Boot')");
                    //收集脚本
                    LuaFunction collectLua = lua.Global.GetInPath <LuaFunction>("CollectScripts");
                    if (collectLua != null)
                    {
                        string[] scripts = collectLua.Func <bool, string[]>(true);
                        if (scripts == null || scripts.Length == 0)
                        {
                            JW.Common.Log.LogE("Collect lua scripts failed.");
                        }
                        else
                        {
                            for (int i = 0; i < scripts.Length; i++)
                            {
                                lua.DoString(string.Format("require('{0}')", scripts[i]));
                                if ((i + 1) % 10 == 0)
                                {
                                    yield return(null);
                                }
                            }
                        }
                    }
                    collectLua = null;
                    if (callback != null)
                    {
                        callback(LoadStateSuccess);
                    }
                    yield return(null);

                    Log.LogD("Load main_lua All Done!");
                    _curLuaZip.Close();
                    _curLuaZip = null;
                }
            }
        }