예제 #1
0
        public static string ReadTextFileFromResources(string path, ZipDelegate zip = null)
        {
            string result = null;

            if (Application.isPlaying)
            {
                string ext = Path.GetExtension(path);
                NSUtils.Assert(string.IsNullOrEmpty(ext) || ext == ".txt" || ext == ".json", "FileUtils: Text file in Resources folder must be '*.txt', '*.json' or none extends format!");
                if (!string.IsNullOrEmpty(ext))
                {
                    path = path.Replace(ext, "");
                }
                TextAsset txt = Resources.Load <TextAsset> (path);
                NSUtils.Assert(txt != null, "No file found at {0}", path);
                result = txt.text;
            }
            else if (File.Exists(path))
            {
//				result = System.IO.File.ReadAllText(path);
                result = ReadStringFromPath(path);
            }
            if (zip != null)
            {
                result = zip.unZip(result);
            }
            return(result);
        }
예제 #2
0
		public static string ReadTextFileFromURL(string url, ZipDelegate zip=null){
			WWW www = new WWW(url);
			while(!www.isDone){}
			string text = www.text;
			if (zip != null)
				text = zip.unZip (text);
			return text;
		}
예제 #3
0
 public static void WriteToFile(string path, string text, ZipDelegate zip = null)
 {
     if (zip != null)
     {
         text = zip.zip(text);
     }
     PlayerPrefs.SetString(path, text);
 }
예제 #4
0
		public static void WriteToFile(string path, string text, ZipDelegate zip=null){
			CCDebug.Log ("FileUtils:writeToFile {0}", path);
			if (zip != null)
				text = zip.zip (text);
			if (File.Exists (path)) {
				File.Delete(path);
			}
			File.WriteAllText (path, text);
		}
예제 #5
0
		public static string ReadTextFileFromExternal(string path, ZipDelegate zip=null){
			string result = null;
			if (File.Exists (path)) {
				result = ReadStringFromPath(path);
			}
			if (zip != null)
				result = zip.unZip (result);
			return result;
		}
예제 #6
0
		public static string ReadTextFileFromStreamAssets(string path, ZipDelegate zip=null){
			string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, path);
			string result = null;
			if (filePath.Contains("://")) {
				result = ReadTextFileFromURL(filePath, zip);
			} else{
				result = ReadStringFromPath(path);
				if (zip != null)
					result = zip.unZip (result);
			}
			return result;
		}
예제 #7
0
 public static void WriteToFile(string path, string text, ZipDelegate zip = null)
 {
     CCDebug.Log("FileUtils:writeToFile {0}", path);
     if (zip != null)
     {
         text = zip.zip(text);
     }
     if (File.Exists(path))
     {
         File.Delete(path);
     }
     File.WriteAllText(path, text);
 }
예제 #8
0
        public static string ReadTextFileFromExternal(string path, ZipDelegate zip = null)
        {
            string result = PlayerPrefs.GetString(path);

            if (result != null && result.Trim().Length == 0)
            {
                result = null;
            }
            if (zip != null)
            {
                result = zip.unZip(result);
            }
            return(result);
        }
예제 #9
0
        public static string ReadTextFileFromExternal(string path, ZipDelegate zip = null)
        {
            string result = null;

            if (File.Exists(path))
            {
                result = ReadStringFromPath(path);
            }
            if (zip != null)
            {
                result = zip.unZip(result);
            }
            return(result);
        }
예제 #10
0
        public static string ReadTextFileFromURL(string url, ZipDelegate zip = null)
        {
            WWW www = new WWW(url);

            while (!www.isDone)
            {
            }
            string text = www.text;

            if (zip != null)
            {
                text = zip.unZip(text);
            }
            return(text);
        }
예제 #11
0
		public static string ReadTextFileFromResources(string path, ZipDelegate zip=null){
			string result = null;
			if (Application.isPlaying) {
				NSUtils.Assert (path.EndsWith (".txt"), "FileUtils: Text file in Resources folder must be '*.txt' format!");
				string ext = Path.GetExtension(path);
				path = path.Replace (ext, "");
				TextAsset txt = Resources.Load<TextAsset> (path);
				NSUtils.Assert (txt!=null, "No file found at {0}", path);
				result = txt.text;
			}else if (File.Exists (path)) {
//				result = System.IO.File.ReadAllText(path);
				result = ReadStringFromPath(path);
			}
			if (zip != null)
				result = zip.unZip (result);
			return result;
		}
예제 #12
0
        public static string ReadTextFileFromStreamAssets(string path, ZipDelegate zip = null)
        {
            string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, path);
            string result   = null;

            if (filePath.Contains("://"))
            {
                result = ReadTextFileFromURL(filePath, zip);
            }
            else
            {
                result = ReadStringFromPath(filePath);
                if (zip != null)
                {
                    result = zip.unZip(result);
                }
            }
            return(result);
        }
예제 #13
0
		public static void WriteToFile(string path, string text, ZipDelegate zip=null){
			if (zip != null)
				text = zip.zip (text);
			PlayerPrefs.SetString (path, text);
		}
예제 #14
0
		public static string ReadTextFileFromExternal(string path, ZipDelegate zip=null){
			string result = PlayerPrefs.GetString (path);
			if(result!=null && result.Trim().Length==0){
				result = null;
			}
			if (zip != null)
				result = zip.unZip (result);
			return result;
		}
예제 #15
0
        private void btnGen_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }
            _manifest.WebSite     = txtWebsite.Text.Trim();
            _manifest.ReleaseDate = DateTime.Now.ToString();
            _manifest.Packaged    = chkZip.Checked;

            if (!chkZip.Checked)
            {
                var files = new List <ReleaseFile>();
                foreach (DataGridViewRow gr in gridFileList.Rows)
                {
                    gr.DefaultCellStyle.BackColor = SystemColors.Window;
                    var selected = Convert.ToBoolean(gr.Cells[ColSelect.Name].Value);
                    if (!selected)
                    {
                        continue;
                    }
                    var fileName = gr.Cells[ColFileName.Name].Value.ToString();
                    if (fileName.StartsWith("["))
                    {
                        continue;
                    }

                    if ((gr.Cells[ColFileVersion.Name].Value == null ||
                         gr.Cells[ColFileVersion.Name].Value.ToString().Trim().Length == 0))
                    {
                        Common.ShowError(gr.Cells[ColFileName.Name].Value + " no version ?");
                        gridFileList.FirstDisplayedScrollingRowIndex = gr.Index;
                        gr.DefaultCellStyle.BackColor = Color.Yellow;
                        return;
                    }
                    files.Add(
                        new ReleaseFile
                    {
                        FileName = fileName,
                        FileSize = long.Parse(gr.Cells[ColSize.Name].Value.ToString()),
                        Version  = gr.Cells[ColFileVersion.Name].Value.ToString()
                    });
                }
                _manifest.Files = files;
            }

            var di = new DirectoryInfo(_buildDir);

            CopyFiles();

            var manifestConfigFile = Path.Combine(_buildDir, Manifest.ManifestFileName);

            _manifest.SaveManifest(manifestConfigFile);
            File.Copy(manifestConfigFile, Path.Combine(di.Parent.FullName, Manifest.ManifestFileName), true);
            File.Copy(manifestConfigFile, Path.Combine(_versionFolder, Manifest.ManifestFileName), true);

            if (chkZip.Checked)
            {
                _zipName = string.Format("{0}_{1}{2}", _manifest.AppName, _manifest.ReleaseVersion, Common.ZipExt);
                _zipPath = string.Format("{0}\\{1}", di.Parent.FullName, _zipName);
                var d = new ZipDelegate(ZipUtil.ZipFolder);
                d.BeginInvoke(_versionFolder, _zipPath, ZipCompleted, null);
            }
            else
            {
                DialogResult = DialogResult.OK;
            }
        }