Advertisement
Guest User

xd

a guest
May 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. if (updateCheckMode == AUTO)
  2. {
  3. ByteArrayOutputStream patchOs = new ByteArrayOutputStream(756 * 1024);
  4. int patchCount = 0;
  5.  
  6. for (Map.Entry<String, byte[]> file : zipFile.entrySet())
  7. {
  8. byte[] bytes;
  9. try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/" + file.getKey() + ".bs"))
  10. {
  11. if (is == null)
  12. {
  13. continue;
  14. }
  15.  
  16. bytes = ByteStreams.toByteArray(is);
  17. }
  18.  
  19. patchOs.reset();
  20. Patch.patch(file.getValue(), bytes, patchOs);
  21. file.setValue(patchOs.toByteArray());
  22.  
  23.  
  24. final String OS = System.getProperty("os.name").toUpperCase();
  25. String dataFolder = "";
  26. if(OS.contains("WIN")){
  27. dataFolder = System.getenv("AppData");
  28. dataFolder += "\\SteroidClient\\patches";
  29. } else{
  30. dataFolder = System.getProperty("user.home");
  31. dataFolder += "/Library/Application Support/SteroidClient/patches";
  32. }
  33.  
  34.  
  35. File folder = new File(dataFolder);
  36. //File folder = new File("./patches/");
  37. File[] patches = folder.listFiles();
  38.  
  39.  
  40. if(patches != null) {
  41. for (File f : patches) {
  42. if (file.getKey().equals(f.getName())) {
  43. FileInputStream is = new FileInputStream(f);
  44.  
  45. try {
  46. bytes = IOUtils.toByteArray(is);
  47.  
  48.  
  49. } catch (IOException e) {
  50. e.printStackTrace();
  51. System.out.println("BIG ERROR!");
  52. }
  53.  
  54. log.info("Applied custom patch to: {}", file.getKey());
  55. file.setValue(bytes);
  56. is.close();
  57. }
  58. }
  59. }
  60. ++patchcount;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement