Changes between Version 7 and Version 8 of FileCompression


Ignore:
Timestamp:
Mar 4, 2008, 10:55:18 AM (16 years ago)
Author:
Kevin Reed
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FileCompression

    v7 v8  
    44
    55If you include the `<gzip_when_done>` tag in an [XmlFormat#Files output file description], the file will be gzip-compressed after it has been generated.
     6
     7The gzip_when_done is only supported in client version 5.8 (version # needs to be confirmed) and more recently.  If you will receive files from clients that do not support the gzip_when_done flag then you should open the files with a function similar to this:
     8
     9int read_gzip_file_string(string file, string* result) {
     10    FILE *infile;
     11    char cmd[512];
     12    char buf[4096];
     13    result->erase();
     14
     15    //build the command
     16    cmd[0]='\0';
     17    strcat(cmd, "gzip -dcf ");
     18    strcat(cmd, file.c_str());
     19
     20    infile = popen(cmd, "r");
     21    if (infile == NULL) {
     22        return ERR_FOPEN;
     23    }
     24
     25    while( fgets(buf, 4096, infile) != NULL ) {
     26        result->append(buf);
     27    }
     28    result->append("\0");
     29    if (pclose(infile) != 0) {
     30            fprintf(stderr, "%s: pclose failed\n", file.c_str());
     31            return 1;
     32    }
     33    return 0;
     34}
     35
     36This will automatically uncompress the file if it is compressed or it will open it without modification if it is not compressed.
     37
    638
    739== Compression of input files == #compress-input