Пример #1
0
 /// <summary>
 /// 解压App压缩包至App id 命名的文件夹下,并返回该文件夹下第一个子文件夹名称
 /// </summary>
 /// <param name="basePath"></param>
 /// <param name="firstDirName"></param>
 public static void ExtractAppData(ref string basePath, ref string firstDirName)
 {
     Vesal_DirFiles.DelectDir(basePath);
     Vesal_DirFiles.CreateDir(basePath + "/");
     Vesal_DirFiles.UnZip(basePath, basePath + "/", true);
     basePath     = basePath + "/";
     firstDirName = Vesal_DirFiles.GetFirstDirInDir(basePath);
 }
Пример #2
0
 /// <summary>
 /// 解压App压缩包至App id 命名的文件夹下,并返回该文件夹下第一个子文件夹名称
 /// </summary>
 /// <param name="basePath"></param>
 /// <param name="firstDirName"></param>
 public static void ExtractAppData(ref string basePath, ref string firstDirName)
 {
     UnityEngine.Debug.Log("ExtractAppData:" + PublicClass.app.app_id);
     UnityEngine.Debug.Log("ExtractAppData:" + basePath);
     Vesal_DirFiles.DelectDir(basePath);
     Vesal_DirFiles.CreateDir(basePath + PublicClass.app.app_id + "/");
     Vesal_DirFiles.UnZip(basePath + PublicClass.app.ab_path, basePath + PublicClass.app.app_id + "/", true);
     basePath     = basePath + PublicClass.app.app_id + "/";
     firstDirName = Vesal_DirFiles.GetFirstDirInDir(basePath);
 }
Пример #3
0
 public static void Vesal_DirCopy(string scr_path, string des_path)
 {
     try
     {
         string[] files = Directory.GetFiles(scr_path);
         foreach (string fn in files)
         {
             string new_fn = fn.Replace("\\", "/");
             string name   = Vesal_DirFiles.get_file_name_from_full_path(new_fn);
             File.Copy(fn, des_path + "/" + name, true);
         }
     }
     catch
     {
     }
 }
Пример #4
0
        public static IEnumerator unzipInThread(string sourcePath, string targetPath, Action callback = null)
        {
            Thread thread = new Thread(() => {
                Vesal_DirFiles.UnZip(sourcePath, targetPath);
            });

            thread.Start();
            yield return(null);

            while (thread.ThreadState != System.Threading.ThreadState.Stopped)
            {
                yield return(null);
            }
            if (callback != null)
            {
                callback();
            }
        }
Пример #5
0
        //异步copy 单个文件
        public static IEnumerator Vesal_FileCopy(string scr_path, string des_path, Action callback)
        {
            UnityEngine.Debug.Log(scr_path);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            if (!scr_path.StartsWith("file://"))
            {
                scr_path = "file://" + scr_path;
            }
#endif
            UnityEngine.Debug.Log("________scr_path:" + scr_path);
            WWW www = new WWW(scr_path);
            yield return(www);

            des_path = des_path.Replace("\\", "/");
            // UnityEngine.Debug.Log("_______des_path:"+des_path);
            try {
                if (!string.IsNullOrEmpty(www.error))
                {
                    vesal_log.vesal_write_log("www.error:" + www.error);
                    UnityEngine.Debug.Log("www.error:" + www.error);
                }
                else
                {
                    UnityEngine.Debug.Log(Vesal_DirFiles.get_dir_from_full_path(des_path));
                    if (File.Exists(des_path))
                    {
                        // UnityEngine.Debug.Log("File.Exists(des_path):"+ File.Exists(des_path));
                        File.Delete(des_path);
                    }
                    Vesal_DirFiles.CreateDir(Vesal_DirFiles.get_dir_from_full_path(des_path));
                    FileStream fsDes = File.Create(des_path);
                    fsDes.Write(www.bytes, 0, www.bytes.Length);
                    fsDes.Flush();
                    fsDes.Close();
                    callback();
                }
                www.Dispose();
            }
            catch (Exception e) {
                UnityEngine.Debug.Log("Exception:" + e.Message);
                UnityEngine.Debug.Log(e.StackTrace);
            }
        }