fclose(fp);
string command = "gzip --force --best " + file.str();
- system(command.c_str());
+ int err = system(command.c_str());
+ if (err)
+ {
+ cout << "ERROR: gzip " << file.str() << " failed!" << endl;
+ }
- return true;
+ return (err == 0);
}
void SGBinObject::read_properties(gzFile fp, int nproperties)
for (k = 0; k < RGB3; k++)
ibuffer[q++] = (unsigned char)
*(buffer + (pixelSize*((win_height-1-i)*win_width+j)+k));
- fwrite(ibuffer, sizeof(unsigned char), RGB3*win_width*win_height, fp);
+ int written = fwrite(ibuffer, sizeof(unsigned char), RGB3*win_width*win_height, fp);
fclose(fp);
free(ibuffer);
+ if ( written != RGB3*win_width*win_height )
+ {
+ printf("Warning: failed to write %s. File truncated.\n", filename);
+ return false;
+ }
+
printf("wrote file '%s' (%d x %d pixels, %d bytes)\n",
filename, win_width, win_height, RGB3*win_width*win_height);
return true;
virtual ~SGSoundSample ();
/**
- * Detect wheter this audio sample holds the information of a sound file.
+ * Detect whether this audio sample holds the information of a sound file.
* @return Return true if this audio sample is to be constructed from a file.
*/
inline bool is_file() const { return _is_file; }
}
/**
- * Test if static dataa of audio sample configuration has changed.
+ * Test if static data of audio sample configuration has changed.
* Calling this function will reset the flag so calling it a second
* time in a row will return false.
* @return Return true is the static data has changed in the mean time.
errno = 0;
while (1) {
- fgets(buffer, 256, infile);
+ (void) fgets(buffer, 256, infile);
if (feof(infile)) {
break;
}