ArcachePoc.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Bsm.Core.Arcache;
  8. using Xunit;
  9. namespace Bsm.Core.Tests
  10. {
  11. public class ArcachePoc
  12. {
  13. [Fact]
  14. public void CreateArchivePoc()
  15. {
  16. var dir = @"Z:\BeatSaverAll";
  17. var arc = new Lz4ArchiveCreator(@"z:\bsa");
  18. IoUtil.LookupFilesRecursively(dir, (p, f) =>
  19. {
  20. if (Path.GetExtension(p.cFileName)?.ToLower() != ".dat") return;
  21. var archivePath = f.TrimStart('/') + "/" + p.cFileName;
  22. var fullPath = Path.Combine(dir, archivePath);
  23. //TODO: add to archive
  24. arc.AppendFile(fullPath, archivePath);
  25. });
  26. arc.Close();
  27. }
  28. [Fact]
  29. public void ReadArchivePocA()
  30. {
  31. var fileBase = @"Y:\BeatSaverAll\bsa";
  32. var arc = new Lz4ArchiveReader(fileBase, false);
  33. var find = arc.Entries.Where(p => p.Key.StartsWith("715f")).FirstOrDefault();
  34. var json = arc.ReadText(arc.Entries["10000 (Athaza - DirtSquirrel)/ExpertPlusStandard.dat"], Encoding.UTF8);
  35. var json2 = arc.ReadText(arc.Entries["1008 (Backbone - fafurion)/info.dat"], Encoding.UTF8);
  36. var json3 = arc.ReadText(arc.Entries["abe8 (pa pa ya!! - barry seggai)/info.dat"], Encoding.UTF8);
  37. var totalSize = arc.Entries.Values.Sum(p => p.OriginalSize);
  38. var kb = totalSize / 1024f;
  39. var mb = kb / 1024f;
  40. var gb = mb / 1024f;
  41. }
  42. [Fact]
  43. public void ReadArchivePocB()
  44. {
  45. var fileBase = @"Z:\SVA\bsa";
  46. var arc = new Lz4ArchiveReader(fileBase, true);
  47. var json = arc.ReadText(arc.Entries["10000 (Athaza - DirtSquirrel)/ExpertPlusStandard.dat"], Encoding.UTF8);
  48. var json2 = arc.ReadText(arc.Entries["1008 (Backbone - fafurion)/info.dat"], Encoding.UTF8);
  49. //10ms
  50. var totalSize = arc.Entries.Values.Sum(p => p.OriginalSize);
  51. var kb = totalSize / 1024f;
  52. var mb = kb / 1024f;
  53. var gb = mb / 1024f;
  54. }
  55. [Fact]
  56. public void ReadLenArchivePoc()
  57. {
  58. var arc = @"z:\bsl";
  59. var dic = LengthPack.Read(arc);
  60. }
  61. }
  62. }