Guest User

Untitled

a guest
Nov 22nd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Stream stream = null;
  2. if (loadFromResources == true)
  3. {
  4. TextAsset textAsset = Resources.Load(fullPath) as TextAsset;
  5. Debug.Log(textAsset);
  6. stream = new MemoryStream(textAsset.bytes);
  7. }
  8. else
  9. {
  10. FileInfo fi1 = new FileInfo(fullPath);
  11. if (fi1.Extension.Equals(".gz"))
  12. {
  13. stream = new MemoryStream();
  14. byte[] buffer = new byte[4096];
  15.  
  16. using (Stream inGzipStream = new GZipStream(File.Open(fullPath,FileMode.Open), CompressionMode.Decompress))
  17. {
  18. int bytesRead;
  19. while ((bytesRead = inGzipStream.Read(buffer, 0, buffer.Length)) > 0)
  20. {
  21. stream.Write(buffer, 0, bytesRead);
  22. }
  23. }
  24.  
  25. }
  26. else
  27. stream = File.Open(fullPath, FileMode.Open);
  28. }
  29. using (BinaryReader reader = new BinaryReader(stream))
  30. {
  31. //header headerKey substruct:
  32. headerKey.sizeof_hdr = reader.ReadInt32(); //ERROR
  33. }
Add Comment
Please, Sign In to add comment