zip unzip ityes, i used a line from a daft punk song
27 Replies - 2069 Views - Last Post: 22 March 2011 - 09:46 AM
#16
Re: zip unzip it
Posted 16 August 2010 - 10:21 AM
#17
Re: zip unzip it
Posted 16 August 2010 - 10:35 AM
Oler1s, on 16 August 2010 - 12:21 PM, said:
I may have failed the sanity check and need to make a will save.
I must admit the post was hard to understand at first as I had not heard that word, but that is neither here nor there.
That said, I see how they are not necessarily one and the same although related (I think that was what you were shooting for when you said orthogonal). If you would, please explain that to me a little more. Mostly because I assumed that the zlib library handled both processes (of course in a way that may be hidden from me).
As per my search on [how to make zip files in c++], I came across this list of things. Assuming that these things were correct, I went on to notice that they mentioned the zlib library (one of them mentioned minizip which I also downloaded).
I'm almost sure I'm missing something here, though, so please correct me.
By the way, the input here is helping me greatly.
*edit*
I noticed this upon further research. Would this be my needed item?
This post has been edited by omochan: 16 August 2010 - 10:37 AM
#18
Re: zip unzip it
Posted 16 August 2010 - 11:00 AM
Quote
Quote
Quote
The compression part of ZIP allows for a few different methods, one of which is DEFLATE (most widely compatible, basically). zlib implements DEFLATE as part of its own compression implementation, which is why if you were writing a zip program, you might be interested in zlib.
But you obviously aren't done here. All you get from zlib is a compression implementation. You of course have to write your own code to read and archive files. This is why you are stuck. You are looking for a complete zip implementation, but all you get is DEFLATE, and the rest is left to you.
So you need to find a tool or library that handles zipping, as opposed to just deflate compression. The link you got seems to be one option. Another is something like zziplib. And so on.
#19
#20
Re: zip unzip it
Posted 16 August 2010 - 12:19 PM
Oler1s, on 16 August 2010 - 01:00 PM, said:
Quote
Quote
Quote
The compression part of ZIP allows for a few different methods, one of which is DEFLATE (most widely compatible, basically). zlib implements DEFLATE as part of its own compression implementation, which is why if you were writing a zip program, you might be interested in zlib.
But you obviously aren't done here. All you get from zlib is a compression implementation. You of course have to write your own code to read and archive files. This is why you are stuck. You are looking for a complete zip implementation, but all you get is DEFLATE, and the rest is left to you.
So you need to find a tool or library that handles zipping, as opposed to just deflate compression. The link you got seems to be one option. Another is something like zziplib. And so on.
Thank you so much for that answer. Apologies for the delay as I was at lunch at the time. I will look into zziplib.
If I might ask a question, why or how would someone use something like zlib simply to compress an item? Wouldn't there need to be something to decompress or is that simply left to the client computer at which the files arrive?
Admittedly, I don't need to decompress or unarchive, but it seems I will need more if I wish to archive (which is the other half of my endeavor).
Again, thank you.
JackOfAllTrades, on 16 August 2010 - 01:00 PM, said:
I did check that out and added it immediately. At times, I post things only to find the answer moments later. Thank you for the hint, though.
This is good. With people like you guys helping, my c++ fu will be strong in no time.
[edit]
I thought it might be good to tell you what dev tool I am using, so in that vein, I was talking to gabehabe today and picked up [Code::Blocks]. I'm not sure if that helps with these questions, but I know that IDEs can vary on how to implement things from time to time and it's hard to give help without complete information.
This post has been edited by omochan: 16 August 2010 - 12:22 PM
#21
Re: zip unzip it
Posted 16 August 2010 - 01:20 PM
Quote
But let's consider in which compression only makes sense. For example, server sending data. For example, an HTTP server, to serve webpages. In this case, the server is only interested in compressing and sending data. What is done with that data is left to the client.
#22
Re: zip unzip it
Posted 17 August 2010 - 10:21 AM
Oler1s, on 16 August 2010 - 03:20 PM, said:
Quote
But let's consider in which compression only makes sense. For example, server sending data. For example, an HTTP server, to serve webpages. In this case, the server is only interested in compressing and sending data. What is done with that data is left to the client.
I see. Thank you for that info. My end goal is to create a file with a certain archive format, so for my purposes, I don't believe compression will be enough.
If you have used zip_utils before, do you think it would be possible to replace the .zip extension with another one?
#23
Re: zip unzip it
Posted 17 August 2010 - 10:56 AM
Quote
I'm not sure what you find relevant from the .zip extension is. It's just a part of the filename. Use another extension if you like, such as .foo or .bar.
This post has been edited by Oler1s: 17 August 2010 - 10:57 AM
#24
Re: zip unzip it
Posted 17 August 2010 - 12:05 PM
- list file directory
- pick one directory out of the list
- zip/archive that directory
- change the file extension from .zip to the relevant extension
From the item I read about zip_utils, I think it only outputs .zip files, but I'm not sure if someone somewhere has tried to use another extension before and not knowing this, I thought I would ask. If it hasn't been attempted, I'll just try it myself and post my results for anyone else here that might ask a similar question in the future.
As for the four steps I listed above, I have covered the [list file directory] item. My next goal is to get the archiving step handled as I am sure that step two is simple "hey, user, can you type that directory you want zipped in this here box...." and off they go.
I hope I'm not being confusing or unclear and thank you picking up on this topic. I really appreciate you, JackofAllTrades and Anarion for all of the help and insight you've given me so far.
#25
Re: zip unzip it
Posted 17 August 2010 - 12:42 PM
Quote
1. HZIP hz = CreateZip("simple1.zip",0);
2. hz = OpenZip(zipbuf, ziplen, 0);
So the only way you get a .zip extension is if you explicitly take steps to create a file with this extension.
#26
Re: zip unzip it
Posted 17 August 2010 - 01:51 PM
Oler1s, on 17 August 2010 - 02:42 PM, said:
Quote
1. HZIP hz = CreateZip("simple1.zip",0);
2. hz = OpenZip(zipbuf, ziplen, 0);
So the only way you get a .zip extension is if you explicitly take steps to create a file with this extension.
Point noted (and duly so). That said, I will try it and see how it goes. If I can make it any archive type, that cuts out a whole step for me (which is wonderful).
#27
Re: zip unzip it
Posted 19 November 2010 - 10:13 AM
That said, I found out yesterday after sending an email to the R&D team at my company that this is what they use for their programs and plugins:
Quote
The most common and simple to use are all .NET languages; but in the past we have developed C++ plugins as well.
In short, I can use C++, but don't have to. I'm wondering if I should continue anyway for my own education. Since I've already started and all.
What are your thoughts, C++ ninjas?
This post has been edited by omochan: 19 November 2010 - 10:13 AM
#28
Re: zip unzip it
Posted 22 March 2011 - 09:46 AM
I got the idea for how to list the directories (as you may or may not know). After playing around for a while, I have a question -- and it's even specific!
I'm trying to get user input and process that input into a function that will spit out a dir list. Thanks in large part to Gabehabe, this what the main looks like:
int main(){
string spdir;
const char *sdir;
listdir ("C:\\Documents and Settings\\...");
cout << "Choose a folder from the list.";
getline (cin, spdir);
stringstream (spdir) >> sdir;
listdir (sdir);
return 0;
}
If you want an idea, this is what the listdir function looks like:
void listdir (const char *path)
{
// first off, we need to create a pointer to a directory
DIR *pdir = NULL; // remember, it's good practice to initialise a pointer to NULL!
pdir = opendir (path); // "." will refer to the current directory
struct dirent *pent = NULL;
if (pdir == NULL) // if pdir wasn't initialised correctly
{ // print an error message and exit the program
printf ("\nERROR! pdir could not be initialised correctly");
return; // exit the function
} // end if
while (pent = readdir (pdir)) // while there is still something in the directory to list
{
if (pent == NULL) // if pent has not been initialised correctly
{ // print an error message, and exit the program
printf ("\nERROR! pent could not be initialised correctly");
return; // exit the function
}
// otherwise, it was initialised correctly. let's print it on the console:
printf ("%s\n", pent->d_name);
}
// finally, let's close the directory
//closedir (pdir);
}
The listing runs ok. I added the includes for cin, cout, and streamstring. The idea is to take the user input and append it to the longer directory in listdir WITHOUT someone having to type the full path. Something like just typing "this" instead of "C:\Documents and Settings\folder\folder\folder\this\".
Ideas?
|
|

New Topic/Question
Reply





MultiQuote




|