Changes between Version 1 and Version 2 of FileCompression


Ignore:
Timestamp:
May 21, 2007, 3:10:17 PM (17 years ago)
Author:
Nicolas
Comment:

Tweaked formatting: some incorrectly indented paragraphs, added monospacing, added headings to boinc_zip (I think it's easier to read). Also fixed a link and a few typos.

Legend:

Unmodified
Added
Removed
Modified
  • FileCompression

    v1 v2  
    33== Compression of output files ==
    44
    5 If you include the <gzip_when_done> tag in an [http://boinc.berkeley.edu/xml.php#file output file description], the file will be gzip-compressed after it has been generated.
     5If 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.
    66
    77== Compression of input files ==
    88
    9 Starting with version 5.4, the BOINC client is able to handle HTTP Content-Encoding types 'deflate' (zlib algorithm) and 'gzip' (gzip algorithm). The client decompresses these files 'on the fly' and stores them on disk in uncompressed form.
     9Starting with version 5.4, the BOINC client is able to handle HTTP `Content-Encoding` types 'deflate' (zlib algorithm) and 'gzip' (gzip algorithm). The client decompresses these files 'on the fly' and stores them on disk in uncompressed form.
    1010
    1111You can use this in two ways:
    1212
    1313    * Use the Apache 2.0 mod_deflate module to automatically compress files on the fly. This method will work with all BOINC clients, but it will do compression only for 5.4+ clients. Info on how to configure this is below.
    14     * Compress files and give them a filename suffix such as '.gz'. The name used in your <file_info> elements, however, is the original filename without '.gz'.
     14    * Compress files and give them a filename suffix such as '.gz'. The name used in your `<file_info>` elements, however, is the original filename without '.gz'.
    1515
    16       Include the following line in httpd.conf:
     16Include the following line in `httpd.conf`:
    1717
    1818{{{
     
    2121
    2222
    23       This will add the content encoding to the header so that the client will decompress the file automatically. This method has the advantage of reducing server disk usage and server CPU load, but it will only work with 5.4+ clients. Use the 'min_core_version' field of the app_version table to enforce this. You can use this in conjunction because the mod_deflate module allows you to exempt certain filetypes from on-the-fly compression.
     23This will add the content encoding to the header so that the client will decompress the file automatically. This method has the advantage of reducing server disk usage and server CPU load, but it will only work with 5.4+ clients. Use the 'min_core_version' field of the app_version table to enforce this. You can use this in conjunction because the mod_deflate module allows you to exempt certain filetypes from on-the-fly compression.
    2424
    2525Both methods store files uncompressed on the client. If you need compression on the client, you must do it at the application level. The BOINC source distribution includes a version of the zip library designed for use by BOINC applications on any platform (see below).
     
    5252You need to read the Apache 2.0 documentation about this
    5353module to make sure you understand it.
    54 However, our httpd.conf file for these changes includes the following:
     54However, our `httpd.conf` file for these changes includes the following:
    5555{{{
    5656# Enable module
     
    7878
    7979This configuration tells Apache to compress all files served from
    80 the download direction except for files that end with gz,gif,jpg,
    81 jpeg and png.
     80the download direction except for files that end with `gz`,`gif`,`jpg`,`jpeg` and `png`.
    8281An alternate way to specify the files is the following:
    8382{{{
     
    8887</Directory>
    8988}}}
    90 This configuration tells apache to compress only the file types
    91 .faa and .mask served from the download director.
     89This configuration tells Apache to compress only the file types
     90`.faa` and `.mask` served from the download directory.
    9291
    9392== Using boinc_zip ==
     
    104103against to provide basic zip/unzip compression functionality.  It
    105104should only add a few hundred KB to your app (basically like
    106 distributing zip & unzip exe's for different platforms).
     105distributing `zip` & `unzip` executable binaries for different platforms).
    107106
    108 Limitations:  the "unzip" functionality is there, that is you can unzip
     107=== Limitations ===
     108The "unzip" functionality is there, that is you can unzip
    109109a file and it will create all directories & files in the zip file. 
    110110The "zip" functionality has some limitations due to the cross-platform
     
    113113function which will be explained below.
    114114
    115 Building:  For Windows, you can just add the project "boinc_zip" to your
     115=== Building ===
     116
     117For Windows, you can just add the project "boinc_zip" to your
    116118Visual Studio "Solution" or "Workspace."  Basically just "Insert Existing
    117119Project" from the Visual Studio IDE, navigate over to the boinc/zip
     
    126128to build properly for your platform.
    127129
    128 Also, please note that boinc_zip relies on some BOINC functions that you
    129 will need (and will most likely be in your app already since they are handy)
    130  -- namely boinc/lib/filesys.C and boinc/lib/util.C
     130Also, please note that boinc_zip relies on some BOINC functions that you will need (and will most likely be in your app already since they are handy) -- namely `boinc/lib/filesys.C` and `boinc/lib/util.C`.
    131131
    132 Using:
    133 Basically, you will need to #include "boinc_zip.h" in your app (of course
     132=== Using ===
     133Basically, you will need to `#include "boinc_zip.h"` in your app (of course
    134134your compiler will need to know where it is, i.e. -I../boinc/zip).
    135135
    136 Then you can just call the function "boinc_zip" with the appropriate arguments
    137 to zip or unzip.  There are three overridden boinc_zip's provided:
     136Then you can just call the function `boinc_zip` with the appropriate arguments
     137to zip or unzip.  There are three overloaded boinc_zip's provided:
    138138{{{
    139139int boinc_zip(int bZipType, const std::string szFileZip,
     
    143143int boinc_zip(int bZipType, const char* szFileZip, const char* szFileIn);
    144144}}}
    145 bZipType is ZIP_IT or UNZIP_IT (self-explanatory)
     145`bZipType` is `ZIP_IT` or `UNZIP_IT` (self-explanatory)
    146146
    147 szFileZip is the name of the zip file to create or extract
     147`szFileZip` is the name of the zip file to create or extract
    148148(I assume the user will provide it with the .zip extension)
    149149
    150150The main differences are in the file parameter.  The zip library used was
    151151exhibiting odd behavior when "coexisting" with unzip, particularly in the
    152 wildcard handling.  So a function was made that creates a "ZipFileList" class,
     152wildcard handling.  So a function was made that creates a `ZipFileList` class,
    153153which is basically a vector of filenames.  If you are just compressing a
    154 single file, you can use either the std::string or const char* szFileIn overrides. 
     154single file, you can use either the `std::string` or `const char* szFileIn` overrides. 
    155155
    156 You can also just pass in a "*" or a "*.*" to zip up all files in a directory.
     156You can also just pass in a `*` or a `*.*` to zip up all files in a directory.
    157157
    158 To zip multiple files in a "mix & match" fashion, you can use the boinc_filelist
     158To zip multiple files in a "mix & match" fashion, you can use the `boinc_filelist`
    159159function provided.  Basically, it's a crude pattern matching of files in a
    160160directory, but it has been useful for us on the CPDN project.  Just create a
    161 ZipFileList instance, and then pass this into boinc_filelist as follows:
     161`ZipFileList` instance, and then pass this into `boinc_filelist` as follows:
    162162{{{
    163163bool boinc_filelist(const std::string directory,
     
    168168}}}
    169169if you want to zip up all text (.txt) files in a directory, just pass in:
    170 the directory as a std::string, the pattern, i.e. ".txt", &yourZipList
     170the directory as a `std::string`, the pattern, i.e. ".txt", `&yourZipList`
    171171
    172172The last two flags are the sort order of the file list (CPDN files need to be
    173173in a certain order -- descending filenames, which is why that's the default).
    174 The default is to "clear" your list, you can set that to "false" to keep adding
    175 files to your "ZipFileList".
     174The default is to "clear" your list, you can set that to `false` to keep adding
     175files to your `ZipFileList`.
    176176
    177 When you have created your "ZipFileList" just pass that pointer to boinc_zip.
     177When you have created your `ZipFileList` just pass that pointer to `boinc_zip`.
    178178You will be able to add files in other directories this way.
    179179
    180 There is a "ziptest" Project for Windows provided to experiment, which can
     180There is a `ziptest` Project for Windows provided to experiment, which can
    181181also be run (the "ziptest.cpp") on Unix & Mac to experiment
    182 with how boinc_zip work (just g++ with the boinc/lib/filesys.C & util.C as
     182with how `boinc_zip` work (just g++ with the `boinc/lib/filesys.C` & `util.C` as
    183183described above).