private static CloudItem CreateFather(string path, Dictionary <string, CloudItem> folders) { if (folders.ContainsKey(path)) { return(folders[path]); } if (path.Contains('\\')) { int lastindex = path.LastIndexOf('\\'); string father = path.Substring(0, lastindex); string child = path.Substring(lastindex + 1); folders[path] = new CloudItem(path, child); var parent = CreateFather(father, folders); folders[father].AddChildren(folders[path]); return(folders[path]); } else { folders[path] = new CloudItem(path, path); folders[""].AddChildren(folders[path]); return(folders[path]); } }
public IEnumerable GetChildren(object parent) { CloudItem _parent = parent as CloudItem; if (_parent == null) { return(CloudManager.GetCloudData().children); } return(_parent.children); }
public bool HasChildren(object parent) { CloudItem _parent = parent as CloudItem; if (_parent == null) { return(false); } return(_parent.children.Count > 0); }
public static CloudItem GetCloudData() { if (!SteamRemoteStorage.FileExists("CloudInfo.bson")) { throw new Exception("There's no CloudInfo.bson, but it should exist. " + "Check your Cloud Manager inside TTS."); } if (!SteamRemoteStorage.FileExists("CloudFolder.bson")) { throw new Exception("There's no CloudFolder.bson, but it should exist. " + "Check your Cloud Manager inside TTS."); } var data = GetFile("CloudInfo.bson"); BackupFile("CloudInfo.bson", data); var cloud_info = ParseBson <Dictionary <string, CloudData> >(data); if (cloud_info == null) { throw new Exception("There's something weird with your CloudInfo.bson, " + "which is in your local folder. Please, save it and report it to the github page:"); } var folders = new Dictionary <string, CloudItem>(); var folder_tree_root = new CloudItem("", "root"); folders.Add("", folder_tree_root); var cloud_info_list = cloud_info.Values.OrderBy(d => string.IsNullOrWhiteSpace(d.Folder) ? 0 : d.Folder.Length); foreach (var value in cloud_info_list) { string foldername = string.IsNullOrWhiteSpace(value.Folder) ? "" : value.Folder; if (!folders.ContainsKey(foldername)) { if (foldername.Contains('\\')) { int lastindex = foldername.LastIndexOf('\\'); string father = foldername.Substring(0, lastindex); string child = foldername.Substring(lastindex + 1); folders[foldername] = new CloudItem(foldername, child); if (!folders.ContainsKey(father)) { CreateFather(father, folders); } folders[father].AddChildren(folders[foldername]); } else if (foldername.Length > 0) { folders[foldername] = new CloudItem(foldername, foldername); folders[""].AddChildren(folders[foldername]); } } var item = new CloudItem(foldername, value.Name); item.data = value; item.cloud_url = value.URL; folders[foldername].AddChildren(item); } return(folder_tree_root); }
public void AddChildren(CloudItem child) { children.Add(child); }