static internal void ClearSession() { lock (HashItemsPool) { foreach (string file_path in HashItemsPool.Keys) { HashItems his = (HashItems)HashItemsPool[file_path]; his.fw.Close(); //rewrite the hash item file to remove old values string file_abs_path = file_path; if (!file_abs_path.Contains(":")) { file_abs_path = Log.WorkDir + "\\" + file_abs_path; } string file_abs_path_old = file_abs_path + ".back"; File.Delete(file_abs_path_old); File.Move(file_abs_path, file_abs_path_old); FileWriter fw = new FileWriter(file_abs_path, false, false, -1); foreach (string key in his.Keys) { fw.WriteLine(key, (string)his[key]); } } HashItemsPool.Clear(); } }
/// <summary> /// Create HashItems if these was not created still, else return it from the hash. /// </summary> /// <param name="file_path">file where items are listed</param> /// <returns></returns> public static HashItems GetHashItems(string file_path) { lock (HashItemsPool) { try { HashItems his; if (!HashItemsPool.TryGetValue(file_path, out his)) { his = new HashItems(file_path); HashItemsPool[file_path] = his; } return his; } catch (Exception e) { LogMessage.Exit(e); } return null; } }
/// <summary> /// Create HashItems if these was not created still, else return it from the hash. /// </summary> /// <param name="file_path">file where items are listed</param> /// <returns></returns> public static HashItems GetHashItems(string file_path) { lock (HashItemsPool) { try { HashItems his; if (!HashItemsPool.TryGetValue(file_path, out his)) { his = new HashItems(file_path); HashItemsPool[file_path] = his; } return(his); } catch (Exception e) { LogMessage.Exit(e); } return(null); } }