Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/fileops.c')
-rw-r--r--source/blender/blenlib/intern/fileops.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index ae20eda5a59..3503164ea56 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -153,29 +153,39 @@ int BLI_gzip(char *from, char *to) {
char buffer[10240];
int file;
int readsize = 0;
+ int rval= 0, err;
+ gzFile gzfile;
- gzFile gzfile = gzopen(to,"wb");
- if (NULL == gzfile) return -1;
+ gzfile = gzopen(to, "wb");
+ if(gzfile == NULL)
+ return -1;
- file = open(from,O_BINARY|O_RDONLY);
-
- if (file < 0) return -2;
+ file = open(from, O_BINARY|O_RDONLY);
+ if(file < 0)
+ return -2;
- while ( 1 )
- {
+ while(1) {
readsize = read(file, buffer, 10240);
+
+ if(readsize < 0) {
+ rval= -2; /* error happened in reading */
+ fprintf(stderr, "Error reading file %s: %s.\n", from, strerror(errno));
+ break;
+ }
+ else if(readsize == 0)
+ break; /* done reading */
- if (readsize <= 0) break;
-
- gzwrite(gzfile,buffer,readsize);
+ if(gzwrite(gzfile, buffer, readsize) <= 0) {
+ rval= -1; /* error happened in writing */
+ fprintf(stderr, "Error writing gz file %s: %s.\n", to, gzerror(gzfile, &err));
+ break;
+ }
}
gzclose(gzfile);
close(file);
-
- remove(from);
- return 0;
+ return rval;
}
/* return 1 when file can be written */