LengthPack.cs 725 B

123456789101112131415161718192021222324
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Text;
  4. namespace SongCore.Arcache
  5. {
  6. public static class LengthPack
  7. {
  8. public static Dictionary<string, float> Read(string filePath)
  9. {
  10. var bufLz4 = File.ReadAllBytes(filePath);
  11. var bufRaw = Lz4ArchiveBase.DecompressPickle(bufLz4);
  12. var dic = new Dictionary<string, float>();
  13. var ms = new MemoryStream(bufRaw);
  14. var reader = new BinaryReader(ms, Encoding.UTF8);
  15. while (ms.Position < ms.Length)
  16. {
  17. var ar = reader.ReadString().ToLower();
  18. dic[ar] = reader.ReadSingle();
  19. }
  20. return dic;
  21. }
  22. }
  23. }