Guest User

modifications I made for CE

a guest
Jan 3rd, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.80 KB | None | 0 0
  1. Index: ceguicomponents.pas
  2. ===================================================================
  3. --- ceguicomponents.pas (wersja 1551)
  4. +++ ceguicomponents.pas (kopia robocza)
  5. @@ -10,7 +10,7 @@
  6.  uses
  7.    zstream, Classes, SysUtils, Controls, forms,ComCtrls, StdCtrls, ExtCtrls, Buttons, lcltype,
  8.    dialogs, JvDesignSurface, DOM, typinfo, LResources, JvDesignImp, JvDesignUtils,
  9. -  graphics, math, xmlread,xmlwrite, WSStdCtrls;
  10. +  graphics, math, xmlread,xmlwrite, WSStdCtrls, CustomBase85;
  11.  
  12.  type TCETreeview=class(TCustomTreeview)
  13.    property Align;
  14. @@ -1275,15 +1275,18 @@
  15.  
  16.  
  17.  
  18. -    getmem(outputastext, m.size*2+1);
  19. -    BinToHex(pchar(m.Memory), outputastext, m.Size);
  20. +    //getmem(outputastext, m.size*2+1);
  21. +    //BinToHex(pchar(m.Memory), outputastext, m.Size);
  22.  
  23. -    outputastext[m.size*2]:=#0; //add a 0 terminator
  24. +    //outputastext[m.size*2]:=#0; //add a 0 terminator
  25.  
  26. +    getmem(outputastext, (m.size div 4) * 5 + 5 );
  27. +    BinToBase85(pchar(m.Memory),outputastext,m.Size);
  28. +
  29.      m.free;
  30.  
  31.  
  32. -    Node.AppendChild(doc.CreateElement(name)).TextContent:=outputastext;
  33. +    Node.AppendChild(doc.CreateElement(name)).TextContent:='BASE85'+outputastext;
  34.    finally
  35.      if outputastext<>nil then
  36.        freemem(outputastext);
  37. @@ -1314,10 +1317,23 @@
  38.  
  39.    s:=node.TextContent;
  40.  
  41. -  size:=length(s) div 2;
  42. +  if copy(s,1,6)='BASE85' then
  43. +  begin
  44. +    size:=length(s) - 6; // skip header
  45. +    if (size mod 5) > 1 then
  46. +      size:= (size div 5) * 4 + (size mod 5) - 1
  47. +    else
  48. +      size:= (size div 5) * 4;
  49. +  end
  50. +  else // old method
  51. +    size:=length(s) div 2;
  52. +
  53.    getmem(b, size);
  54.    try
  55. -    HexToBin(pchar(s), b, size);
  56. +    if copy(s,1,6)='BASE85' then
  57. +      Base85ToBin(pchar(s)+6, b) // remember to skip header - pchar(s)+6 instead of pchar(s)
  58. +    else // old method
  59. +      HexToBin(pchar(s), b, size);
  60.  
  61.      m:=tmemorystream.create;
  62.      m.WriteBuffer(b^, size);
  63. Index: luafile.pas
  64. ===================================================================
  65. --- luafile.pas (wersja 1551)
  66. +++ luafile.pas (kopia robocza)
  67. @@ -5,7 +5,7 @@
  68.  interface
  69.  
  70.  uses
  71. -  Classes, SysUtils, DOM, zstream, math;
  72. +  Classes, SysUtils, DOM, zstream, math, CustomBase85;
  73.  
  74.  type TLuafile=class
  75.    private
  76. @@ -36,12 +36,25 @@
  77.  
  78.    s:=node.TextContent;
  79.  
  80. -  size:=length(s) div 2;
  81. +  if copy(s,1,6)='BASE85' then
  82. +  begin
  83. +    size:=length(s) - 6; // skip header
  84. +    if (size mod 5) > 1 then
  85. +      size:= (size div 5) * 4 + (size mod 5) - 1
  86. +    else
  87. +      size:= (size div 5) * 4;
  88. +  end
  89. +  else // old method
  90. +    size:=length(s) div 2;
  91. +
  92.    maxsize:=max(65536,size); //64KB or the required size if that's bigger
  93.  
  94.    getmem(b, maxsize);
  95.    try
  96. -    HexToBin(pchar(s), b, size);
  97. +    if copy(s,1,6)='BASE85' then
  98. +      Base85ToBin(pchar(s)+6, b) // remember to skip header - pchar(s)+6 instead of pchar(s)
  99. +    else // old method
  100. +      HexToBin(pchar(s), b, size);
  101.  
  102.      m:=tmemorystream.create;
  103.      m.WriteBuffer(b^, size);
  104. @@ -74,14 +87,16 @@
  105.    c.write(filedata.Memory^, filedata.size);
  106.    c.free;
  107.  
  108. -  //convert the compressed file to a hexstring
  109. -  getmem(outputastext, m.size*2+1);
  110. +  //convert the compressed file to a BASE85   (before hexstring)
  111. +  //getmem(outputastext, m.size*2+1);
  112. +  getmem(outputastext, (m.size div 4) * 5 + 5 );
  113.    try
  114. -    BinToHex(pchar(m.Memory), outputastext, m.Size);
  115. +    //BinToHex(pchar(m.Memory), outputastext, m.Size);
  116. +    BinToBase85(pchar(m.Memory), outputastext, m.Size);
  117.  
  118. -    outputastext[m.size*2]:=#0; //add a 0 terminator
  119. +    //outputastext[m.size*2]:=#0; //add a 0 terminator
  120.      doc:=node.OwnerDocument;
  121. -    Node.AppendChild(doc.CreateElement(name)).TextContent:=outputastext;
  122. +    Node.AppendChild(doc.CreateElement(name)).TextContent:='BASE85'+outputastext;
  123.  
  124.    finally
  125.      freemem(outputastext);
Advertisement
Add Comment
Please, Sign In to add comment