views:

40

answers:

2

I have a possibly pre-existing directory structure on the client machine server that looks like this:

-|
 +css
  |-ABC
  |-EFG
  |-XYZ
 +img
  |-ABC
  |-EFG
  |-XYZ
 +js
  |-ABC
  |-EFG
  |-XYZ
 +htm
  |-ABC
  |-EFG
  |-XYZ

When we send our customers updates to their e-commerce websites we send them in a zip file, which has the following structure:

-|
 +css
  |-UniqueDirectory
 +img
  |-UniqueDirectory
 +js
  |-UniqueDirectory
 +htm
  |-UniqueDirectory

...where UniqueDirectory is always the same name.

That being said, is there a way using Visual C++ 2005 that a program could be written to unzip the zip file that we send the customer into the existing directory without overwriting any of the existing directories (excluding the UniqueDirectory of course, that can and should be overwritten).

The end result after the file being unzipped on the client machine should be:

-|
 +css
  |-ABC
  |-EFG
  |-UniqueDirectory
  |-XYZ
 +img
  |-ABC
  |-EFG
  |-UniqueDirectory
  |-XYZ
 +js
  |-ABC
  |-EFG
  |-UniqueDirectory
  |-XYZ
 +htm
  |-ABC
  |-EFG
  |-UniqueDirectory
  |-XYZ

Can this be done using C++? My clients don't possess the technical skill involved to just unzip the files to the correct directories. They also don't necessarily want to install an unzipping program.

Would it require an external library? Preferably I'd like to do this using just libraries from Visual C++ 2005, but if an external library is required I'd like to know what it is called.

A: 

No, MFC/ATL do not have such capability. Unless you count the J# redistributable that is installed with Visual Studio and can be used via C++/CLI, you need an external library or reinvent the wheel.

Sheng Jiang 蒋晟
+2  A: 

Unless you want to implement the compression/decompression algorithm yourself using only what is available with VS2005, you'll want to look in to using a library to do your work for you. I recommend zlib. It's free.

There's a how-to on the site.

Edit: In response to the question in your comment, yes it is old enough to be build by VS2005. I just downloaded the latest source and was able to compile it into a .dll. The copy I downloaded was "zlib source code, version 1.2.3, zipfile format". After you extract the files, look for the /projects/visualc6/ directory. You should be able to build the library from there.

Alternatively you can also download a pre-compiled library from the zlib site. It's listed with the source file downloads as "zlib compiled DLL, version 1.2.3, zipfile format".

Edit: Keep in mind that zlib is a C library. If you're looking for a C++ library, you might try gzstream, which is basically a C++ wrapper around zlib.

Zack Mulgrew
Is it old enough that it will work with VS2005? If so what version should I use?
leeand00
yes, zlib will work with VC2005. In fact you can build it with VC2005, so you could statically link it into your project. Use version 1.2.3 or later. (I just ran this build yesterday)
Cheeso