www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.zlib and other tools

reply Jesse Phillips <jessekphillips+D gmail.com> writes:
I'm just wondering if anyone else has an issue with using std.zlib with other
programs such as gzip and 7-zip? zlib creates and loads gz files right?

The library works perfectly with itself, but I can't read or write compressed
files from other popular programs.

mport std.stdio;
import std.file;
import std.zlib;
auto searchFolder = r".";

void main() {
   foreach(string de; dirEntries(searchFolder, SpanMode.shallow)) {
      if(de[$-"gz".length..$] != "gz") {
         auto data = read(de);
         std.file.write(de ~ ".gz", compress(data));
      }
   }
   foreach(string de; dirEntries(searchFolder, SpanMode.shallow)) {
      if(de[$-"gz".length..$] == "gz") {
         auto data = read(de);
         std.file.write(de ~ ".txt", uncompress(data));
      }
   }
}
Mar 02 2011
parent reply Johannes Pfau <spam example.com> writes:
Jesse Phillips wrote:
I'm just wondering if anyone else has an issue with using std.zlib
with other programs such as gzip and 7-zip? zlib creates and loads gz
files right?

The library works perfectly with itself, but I can't read or write
compressed files from other popular programs.

mport std.stdio;
import std.file;
import std.zlib;
auto searchFolder =3D r".";

void main() {
   foreach(string de; dirEntries(searchFolder, SpanMode.shallow)) {
      if(de[$-"gz".length..$] !=3D "gz") {
         auto data =3D read(de);
         std.file.write(de ~ ".gz", compress(data));
      }
   }
   foreach(string de; dirEntries(searchFolder, SpanMode.shallow)) {
      if(de[$-"gz".length..$] =3D=3D "gz") {
         auto data =3D read(de);
         std.file.write(de ~ ".txt", uncompress(data));
      }
   }
}
I think this could be the reason: http://zlib.net/zlib_faq.html#faq18 --=20 Johannes Pfau
Mar 02 2011
parent Jesse Phillips <jessekphillips+D gmail.com> writes:
I must have been overwhelmed when I landed on that page last time.

Seems the etc.c.zlib bindings have the needed functions, just don't have it
wrapped in the standard library.

Thanks.
Mar 03 2011