c# - zlib.net compression returning null data -


i'm working on c# app auto create files updater. updater expects array of zlib data(file split 2048 byte sections each compressed). i'm missing minor but, anyway

here's function

 public bool compress(fileinfo file)     {         int max = 0;         int buffsize = 2048;         rppackage pack = new rppackage();         string tmp = "rohan patch v1.0";         pack.header = new char[32];         tmp.copyto(0, pack.header, 0, tmp.length);         if (g.version != 0)             pack.version = pack.oversion = g.version;         else         {             console.writeline("please enter patch file version: ");             g.version = convert.toint32(console.readline());             //g.version = pack.version = pack.oversion = 151132417;         }         pack.type = 10;         pack.omodify = file.lastwritetime;         pack.always1 = 1;         //pack.outputfile = file.name;         pack.outputfile = new char[64];         file.name.copyto(0, pack.outputfile, 0, file.name.length);         tmp = file.directoryname.replace(environment.currentdirectory, "") + @"\";         pack.outputpath = new char[128];         if (tmp.length > 64)             tmp = tmp.substring(0, 64);         tmp.copyto(0, pack.outputpath, 0, tmp.length);         pack.outputsize = (int)file.length;          if( file.extension != "" )             tmp = file.name.substring(0, (int)file.name.length - ((int)file.extension.length)) + "__" + file.extension.substring(1, file.extension.length - 1) + ".rp";         else             tmp = file.name + "__.rp";          pack.remotefile = new char[64];         if (tmp.length > 64)             tmp = tmp.substring(0, 128);         tmp.copyto(0, pack.remotefile, 0, tmp.length);         tmp = @"d:\usapatch\tmpsvn" + new string(pack.outputpath).replace("\0", "").replace("/", @"\");         pack.remotepath = new char[128];         if (tmp.length > 128)             tmp = tmp.substring(0, 128);         tmp.copyto(0, pack.remotepath, 0, tmp.length);         pack.blobs = new rpblob[file.length/2048];         int blobz = 0;         filestream raw = file.openread();         while( blobz < pack.blobs.length )         {             byte[] buff = new byte[buffsize];             byte[] buff2 = new byte[buffsize];             max = raw.read(buff, 0, buffsize);             //console.readkey(true);             memorystream cstrm = new memorystream(buff2);             zlib.zoutputstream gzip = new zlib.zoutputstream(cstrm, zlib.zlibconst.z_default_compression);             memorystream dstrm = new memorystream(buff);             //console.readkey(true);             //copystream(dstrm, gzip);             //dstrm.copyto(gzip);             gzip.write(dstrm.toarray(), 0, (int)dstrm.length);              //gzip.write(buff, 0, buffsize);             pack.blobs[blobz] = new rpblob();             pack.blobs[blobz].u = max;             pack.blobs[blobz].c = (int)cstrm.position;             pack.blobs[blobz].blob = new byte[pack.blobs[blobz].c];             pack.blobs[blobz].blob = cstrm.toarray();               //console.readkey(true);             blobz++;             if (max + buffsize > (int)raw.length)             {                 buffsize = (max + buffsize) - (int)raw.length;                 if (buffsize < 0 || (max + buffsize) > (int)raw.length)                     break;             }         }         string _path, _file;         _path = new string(pack.outputpath).replace("\0", ""); _path = _path.trimend();         _file = new string(pack.remotefile).replace("\0", ""); ; _file = _file.trimend();          if (!directory.exists(@".\patch\data" + _path))             directory.createdirectory(@".\patch\data" + _path);         binarywriter cpr = new binarywriter(file.openwrite(@".\patch\data" + _path + _file));         cpr.write(pack.header);         cpr.write(pack.version);         blobz = 0;         while (blobz < pack.blobs.length )         {             cpr.write(1);             cpr.write(pack.blobs[blobz].u);             cpr.write(pack.blobs[blobz].c);             cpr.write(pack.blobs[blobz].blob, 0, pack.blobs[blobz].c);             blobz++;         }         cpr.write(type(pack));         cpr.write(pack.version);         cpr.write(pack.omodify.tofiletime());         cpr.write(1);         cpr.write(pack.outputfile);         cpr.write(pack.outputpath);         cpr.write(pack.outputsize);         cpr.write(pack.remotefile);         cpr.write(pack.remotepath);         pack.remotesize = (int)cpr.basestream.length + 4;         cpr.write(pack.remotesize);         upload u = new upload();         return u.update(pack);     } 

it should return blobs like

78 9c 63 60 60 60 b0 60 d0 61 f0 f4 8b 77 0d 71 8e 77 f6 71 0c 8f 77 62 20 06 38 15 e5 67 a7 e6 29 38 e7 24 96 13 a5 9e 81 41 01 4a 33 02 71 08 10 0b 02 b1 08 10 ff 47 03 70 f5 8e 5e 20 9c 95 0c b4 23 51 2f bd a4 82 48 8b 80 40 9e 81 9b 78 c5 a3 60 48 00 4b b4 74 ea 4c 94 2e a7 9c d2 bc 12 52 92 29 4a 3a ad 05 12 3e 0c a3 e9 74 14 10 0f ac d0 d2 a9 0b 51 ba 9c 72 f2 f3 53 2a c9 2d 4f ab 98 18 18 ea 19 46 d3 e9 28 20 1e 58 03 d3 29 00 04 9a 5e 09 01 00 00 00 93 00 00 00 00 08 00 00 

however, writes blobs as

78 9c 01 00 00 00 00 08 00 00 02 00 00 00 

i'm using zlib.net library


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -