Link to home
Start Free TrialLog in
Avatar of BeginToLearn
BeginToLearn

asked on

mystery

hi all,
My standalone compress/decompress works perfect. After i imported compress function to my code, it work perfect. However, after import decompress function, it can't decompress the file. As a result, the file is empty. . After i check, it seems gzread() can't read. but the code is just copy and paste. Please tell me what i did wrong. tks a lot.

+ please remove .c in test1a.txt.myziphaha as the input
+ sample.c is the standalone
+ server.c at line 222 is to call decompress.
test1a.txt.myziphaha.c
sample.c
server.c
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BeginToLearn
BeginToLearn

ASKER

gzread always return 0.why my sample can work?

Hmm... weird.  

Do you link the same libraries?

And fred(buffer) above should obviously have been free(buffer).

Kent
verything is same.i cppy n pastr from sample.c .you can take a lok at sample.c .tks a lot.very weird
your suggestion doesn't work. Somehow gzread() always return 0 . but in sample.c, it can return proper value.
ubuntu@ubuntu:~/program$ ./server /home/ubuntu/program/dest1 51000
constructor, dirname: /home/ubuntu/program/dest1
message1-> total number of files is 1
filename:test1a.txt.myziphaha
input:/home/ubuntu/program/dest1/test1a.txt.myziphaha
output:/home/ubuntu/program/dest1/test1a.txt
outside while, num_read:0
ubuntu@ubuntu:~/program$

--> so it can't get in the read/write loop
I have tried all ways, but fail. if I just run sample to decompress it, it works. do you see anything wrong?
I solved it :) reason is I call decompress before fclose() hihi