Search
lxdream.org :: lxdream/src/util.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/util.c
changeset 1042:0fd066956482
prev768:b2a54f6864eb
next1065:bc1cc0c54917
author nkeynes
date Fri Jun 26 13:53:54 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Do the save-to-temp and rename thing when saving VMUs, for the sake of limiting corruption possibilities
file annotate diff log raw
1.1 --- a/src/util.c Thu Jul 24 07:27:48 2008 +0000
1.2 +++ b/src/util.c Fri Jun 26 13:53:54 2009 +0000
1.3 @@ -82,7 +82,7 @@
1.4 return len;
1.5 }
1.6
1.7 -void fwrite_gzip( void *p, size_t sz, size_t count, FILE *f )
1.8 +int fwrite_gzip( void *p, size_t sz, size_t count, FILE *f )
1.9 {
1.10 uLongf size = sz*count;
1.11 uLongf csize = ((int)(size*1.001))+13;
1.12 @@ -91,8 +91,15 @@
1.13 assert( status == Z_OK );
1.14 uint32_t wsize = (uint32_t)csize;
1.15 fwrite( &wsize, sizeof(wsize), 1, f );
1.16 - fwrite( tmp, csize, 1, f );
1.17 + int written = fwrite( tmp, csize, 1, f );
1.18 g_free(tmp);
1.19 +
1.20 + /* Could be finer-grained, but this is enough to know it succeeded/failed */
1.21 + if( written == 1 ) {
1.22 + return count;
1.23 + } else {
1.24 + return 0;
1.25 + }
1.26 }
1.27
1.28 int fread_gzip( void *p, size_t sz, size_t count, FILE *f )
.