Esempio n. 1
0
 public override void Reset()
 {
     if (taskCtrl != null)
     {
         taskCtrl.Cancel();
         taskCtrl = null;
     }
 }
Esempio n. 2
0
    // 基本的にはオープンとやることは同じなんですけど、
    // StreamingAssetにファイルがあるかどうかの確認を行う
    public ThreadQueue.TaskControl AutoOpen(string filename, string _strDirectory, OpenCallback callback, object state)
    {
        string pathDB = System.IO.Path.Combine(Application.persistentDataPath, filename);
        //Debug.Log( pathDB );
        bool bFileCtrlError = false;

        if (!System.IO.File.Exists(pathDB))
        {
            //Debug.Log ("DB not Exists in documents folder");
            //original path
            string sourcePath = System.IO.Path.Combine(Application.streamingAssetsPath, _strDirectory + filename);
            //Debug.Log( sourcePath );
            if (sourcePath.Contains("://"))
            {
                // Android
                WWW www = new WWW(sourcePath);
                // Wait for download to complete - not pretty at all but easy hack for now
                // and it would not take long since the data is on the local device.
                while (!www.isDone)
                {
                    ;
                }
                if (String.IsNullOrEmpty(www.error))
                {
                    System.IO.File.WriteAllBytes(pathDB, www.bytes);
                }
                else
                {
                    bFileCtrlError = true;
                    //CanExQuery = false;
                    // エラーで返す
                }
            }
            else
            {
                // Mac, Windows, Iphone
                //validate the existens of the DB in the original folder (folder "streamingAssets")
                if (System.IO.File.Exists(sourcePath))
                {
                    //copy file - alle systems except Android
                    System.IO.File.Copy(sourcePath, pathDB, true);
                }
                else
                {
                    bFileCtrlError = true;
                    //CanExQuery = false;
                    // エラーで返す
                    Debug.Log("ERROR: the file DB named " + filename + " doesn't exist in the StreamingAssets Folder, please copy it there.");
                }
            }
        }
        if (bFileCtrlError)
        {
            //Debug.Log( "open error");
            ThreadQueue.TaskControl retError = new ThreadQueue.TaskControl();
            retError.Cancel();
            return(retError);
        }

        //Debug.Log( "open:"+pathDB );
        return(Open(pathDB, callback, state));
    }