/** *@brief process all data read from a cache file and process it to construct the database *@param[in] cache_file_data (Dictionary<sulhur.editor.utils.UInt64_s, sulphur.editor.AssetDatabase.PackagePtr>) data to process */ private void ProcessCacheFileData(Dictionary <utils.UInt64_s, PackagePtr> cache_file_data) { if (cache_file_data == null) { return; } foreach (KeyValuePair <utils.UInt64_s, PackagePtr> entry in cache_file_data) { utils.UInt64_s id = entry.Key; PackagePtr ptr = entry.Value; ProcessCacheFileData(id, ptr); } cache_file_data.Clear(); }
/** * @brief Processes a single entry in an asset cache; * @param[in] id (UInt64) id of the asset. * @param[in] ptr (sulphur.editor.AssetDatabase.PackagePtr) Package pointer read from the cache. */ private void ProcessCacheFileData(UInt64 id, PackagePtr ptr) { AssetCacheData cache_data = new AssetCacheData(); DirectoryInfo info = new DirectoryInfo(Project.directory_path + "\\" + ptr.origin); int slash = ptr.path.LastIndexOf("/") + 1; int dot = ptr.path.LastIndexOf("."); cache_data.id = id; cache_data.path = ptr.path; cache_data.origin = info.FullName.ToLower(); cache_data.name = ptr.path.Substring(slash, dot - slash); cache_data.type = GetAssetType(ptr.path); cache_data.is_valid = true; string original_folder = info.FullName.Substring(0, info.FullName.LastIndexOf("\\")).ToLower(); if (data.ContainsKey(original_folder) == false) { AssetList new_list = new AssetList(); new_list.CollectionChanged += OnAssetListChanged; data.Add(original_folder, new_list); } AssetCacheData exists = data[original_folder].Find(cache_data.id, cache_data.type); if (exists.is_valid == true) { Log.Write(Log.Verbosity.kWarning, "Asset {0} allready exists", cache_data.path); return; } App.Current.Dispatcher.Invoke(delegate { data[original_folder].Add(cache_data); }); }