public static void initialize(string path) { Config.path = path; string folder = ShaCache.ToContaingFolder(path); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } if (File.Exists(path) == false) { File.Create(path).Close(); } string txtString = File.ReadAllText(path); string[] lines = txtString.Replace("\r", "").Split("\n"); for (int i = 0; i < lines.Length; i++) { if (!lines[i].Contains("->")) { continue; } string[] mats = lines[i].Split("->"); if (mats.Length == 2) { oneString s = new oneString(); s.original = mats[0]; s.translated = mats[1]; translations.Add(s); } } }
private void DownloadGitFile(string id, GitNode file, string folderPath) { if (Application.internetReachability == NetworkReachability.NotReachable) { throw new Exception("Internet error"); } GitFile download = RequestFromGit <GitFile>(id, file.path); byte[] bytes = Convert.FromBase64String(download.content); string downloadFile = Path.Combine(folderPath, file.path); string downloadDir = ShaCache.ToContaingFolder(downloadFile); if (!Directory.Exists(downloadDir)) { Directory.CreateDirectory(downloadDir); } File.WriteAllBytes(downloadFile, bytes); localSha.UpdateInsertCache(downloadFile, file.id); }
IEnumerator Download(string url, string targetFile) { WWW request = new WWW(url); while (!request.isDone) { yield return(null); } string folder = ShaCache.ToContaingFolder(targetFile); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } if (request.error == null || request.error == "") { File.WriteAllBytes(targetFile, request.bytes); } if (DownloadCardCompleted != null) { DownloadCardCompleted(this, null); } }