I'm trying to zip up all of the files in a certain directory. Does C have any functions that can do this? If not, where can I find some?
I'm trying to zip up all of the files in a certain directory. Does C have any functions that can do this? If not, where can I find some?
No, C has no datacompression function, if that is what you are looking for. Here you can find info on datacompression:
http://www.data-compression.com/
It's not really about compression. I'd like to package 30 word docs into a single .zip file so I can email it.
If it is not about compression than why did you post this thread here?
If you want to compress 30 word documents use Total Commander, WinZIP or use command line zip program.
Current projects:
1) User Interface Development Kit (C++)
2) HTML SDK (C++)
3) Classes (C++)
4) INI Editor (Delphi)
Because I'm trying to do it programatically in C. I'm writing a script that will run each morning on a reporting server. It will zip up the files in a directory and email that zip file out each morning. It is larger scale than this, because there are 20+ folders, but I can easily expand this once I get one folder going.Originally posted by GaPe
If it is not about compression than why did you post this thread here?
BTW, I've already done it in Java. But I'd like to replicate it with C so I can learn about C. Java has a class for this in the SDK.
Here's a task for you :
Write a program to merge a set of files into one file, then it must be able to split that file into the original files. The file names and file sizes can be stored in a text file.
If you already have the zip program installed (say Winzip, for example), maybe you'll get away with simply invoking it from your program in the same way you would do so on the command line.
Check out these which tell you how to spawn child processes.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
zlib is freely available and quite well documented.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
That looks like the perfect solution. Thank you.Originally posted by Stoned_Coder
zlib is freely available and quite well documented.
I'm sure I'll post back with newbie questions. This is all quite new to me.
Ok, I've downloaded the dll for zlib. It has some header files, a dll file, and a lib file. In my project (MSVC++ 6), my project structure looks like this...Originally posted by Stoned_Coder
zlib is freely available and quite well documented.
How do I import the zlib library so I can use it? Do I need to import all of the given files or only the header and dll files? Where do I copy the files to? Thanks in advance. I'm a newb.Code:/Project Root /Debug/ /src/ main.c RptSendMail.dsw etc...
Read the docs.Originally posted by CompiledMonkey
How do I import the zlib library so I can use it? Do I need to import all of the given files or only the header and dll files? Where do I copy the files to? Thanks in advance. I'm a newb.
Quzah.
Hope is the first step on the road to disappointment.
I have been, that's why I waited so long to ask the question. This is also a MSVC++ 6.0 question, I'm curious as to what is considered "best practice" when dealing with header files and importing dlls. Also, overall file structure of applications.Originally posted by quzah
Read the docs.
Quzah.
This (http://www.gzip.org/zlib/manual.html) helps a great deal in what the functions do and how to use them, but it doesn't talk about making them accessable to your app. It assumes you've already got access to them.
include the headers in the source file you use zlib funcs in.
either add the .lib to your project or surf thru the project options to where additional libraries can be specified and add the .lib to the list. This will give you static linkage of the zlib code.
The dll is for dynamic linking zlib code and i think can probably be ignored for now.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Ok, I went to Project -> Add to Project -> Files and added the zlib.lib file. My source file (main.c) and all of my header files are in the /rootDirOfProject/src/ directory. My main.c file includes looks like this:
I'm getting an error when trying to compile. It cannot find the header files.Code:#include <stdio.h> #include <src/ioapi.h> #include <src/unzip.h> #include <src/zconf.h> #include <src/zip.h> #include <src/zlib.h>
Code:Cannot open include file: 'src/ioapi.h': No such file or directory
you should move the headers to a subdirectory of your compilers include directory.Then include them as <suddirname/headername.h> and all should be well.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi