- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Somebody else can have fist comment. That hurts my eyes too much to read through it.
Admin
inb4 .mkv!
Admin
How is this zipping? What part of that script actually zips anything?
Admin
No wonder the C guys think VB sucks if this is their only experience of it!
Admin
Jeez - just pay for Winzip command line already.
Admin
You're going to make me read code first thing Monday morning to find teh funnay? That's cold blooded... ;)
Admin
So, it's not a zip, but a self-extracting tar, disguised in vb. Not bad.
Admin
I like this: CString m_outputfilename = m_outfile; CString outpath = outfolder;
That's classy coding right there. He never uses outfile or outfolder again. He names them in the function, and then promptly renames them in the first two lines of the function.
Quality stuff.
Admin
Mmmmm, meta-spaghetti. Things I like best:
Admin
Admin
It looks like it uses vbscript to output a script to do the actual compression, then runs it.
It outputs an empty ZIP file and then uses the Windows Explorer ZIP shell extension to mimic the user ability to drag and drop files into that ZIP and have them automatically compressed. Clearly the programmer didn't know how to do this directly from C and couldn't be arsed to RTFM.
Of course if the user disables the shell extension or is on an earlier Windows OS that doesn't have it, the program fails with no error.
A more fool-proof solution would have been to use an external process like 7za.exe (7-zip), which, AFAIK, can be bundled as long as you include the license. Of course a library would be even better.
Admin
this guy/girl is not stupid or inexperienced... the function is actually very clever ... i love how the text file with the PK+magic number signature is written and it turns automatically into folder where the files are be copied ...
Admin
Jesus Christ, this code has just made my day even worse.
Admin
Sorry, couldn't resist :
My eyes ! The goggles, they do nothing !!
Admin
Adding three more to my list:
Admin
Apart from the fact that the code itself is irredeemably retarded, I wonder if it'll work if Explorer isn't the handler for .zip files...
Admin
The real WTF is the comments:
//find temp directory; dwRetVal = GetTempPath(dwBufSize, //buffer length lpPathBuffer); //path buffer
//get the windows directory; dwRetVal = GetWindowsDirectory(lpPathBuffer1,dwBufSize); //path buffer
Without these comments I'd have spend all of, err, 1 nano-second working out that GetTempPath let me find a temp directory and that GetWindowsDirectory would let me, err, get the windows directory.
Admin
Admin
Thank the lord for VB being a Windows only technology. The ZIP header and folder thing is very clever thought. What I don't seem to find is if this thing truly does any compression.
Admin
I think C++ just scared the shit out of him and tried to solve it by using VB =)
Admin
Real programmers can write VB in any language.
At least after someone showed them how to i/o-stream.
Admin
(Making the header inside a .vbs file written from C++? Priceless.)
Admin
The real WTF is that the attempt to be 64-bit compliant isn't correct.
Admin
With the Matryoshka doll comment I was expecting to see it zip individual files, then zip the folder of zip files recursively giving you a zip of zips of zips, and so on. But this, is so much more insidiously retarded.
Admin
Or, repeatedly zip the same file until you reach the singularity of the 1 bit file.
Admin
At first I just saw the large group of fprintf calls, and I thought "Okay, he's just writing a bunch of headers" then I looked closer and... Oh dear god no.
Admin
He needed something in order to zip a folder full of files?
Geez...
...get tar and gzip. It's open source.
Admin
Yeah, I was expecting something that only added one file at a time to the zip, but that kept creating a zip and adding the previous zip to it instead so you end up with one file zipped N times instead of N files in a zip (or maybe adding one file with each level so you end up with something like a list in Lisp). I guess the "nesting" is just the C program writing VB.
Admin
I've been doing that for a while now. I think the process is almost done.
1 <== The entire Internet.
Admin
"Jeez - just pay for Winzip command line already."
Glad you didn't write this either! The best solution would be to use the minizip library (in zlib/contrib).
Admin
I like the way he runs "cmd.exe /c cscript //B " + filename instead of just "cscript /B " + filename...
Admin
TRWTF is that the "Full Article" view displays the exact same thing as the Summary view.
Admin
misleading indentation:
And anyway, what is this RESID_30 string? A double quote? Couldn't he be bothered to look up how to escape a double quote inside A C++ string?
Admin
"cmd.exe /c ..." spawns a new shell thread while "cscript /B" would block the program flow
Admin
np: Tocotronic - Über Sex Kann Man Nur Auf Englisch Singen (Digital Ist Besser)
Admin
Actually, once the zips of zips reached a sufficiently high level of disorder the combined size of all the zips would start to grow because each iteration adds a small amount of overhead to the file. Eventually the process would create a file consuming all secondary storage on the host system.
-Lego
Admin
Admin
Alright class, this is a nice example of someone not getting the joke, or - even worse - getting the joke and still acting like it was serious. Now, can anyone point me where he failed his "Spot sarcasm" check?
Admin
I don't know why everybody's acting like this makes their eyes bleed. Is it dumb to have your C++ code write your VBScript for you? Sure. But if you're stuck on an XP machine (and you know it will always be at least XP) and there are procedural hurdles to importing/using 3rd-party software, VBScript is the way to go. Sad, but true.
I grant you that he should have broken out the VBScript in a separate file and just invoked it as if it were a command-line zip util, but the basic concept is sound. Of course, I make no excuses for the quality of the rest of his code...
Admin
Whoosh!
Admin
This kind of stuff drives me crazy. No comments on the heart of the algorithm or on WTF s/he is doing... But s/he takes the time to tell us that dwBufSize is the size of the buffer and lpPathBuffer is the path buffer. Gee, thanks for nothing!
Admin
Prime example of why comments should tell why not what. I only hope the young whippersnappers are listening.
Admin
Hard coded paths = the programming equivalent of murdering kittens. Seriously. Don't put files on my damn C:\ drive root. I don't care if you can't find your temp folder.
Also: can't he just use the system environment variables that VBS already gives you?
Aside from how retarded this is (what if you've disabled the Windows zip functionality? I know I have), it's actually kind of an intriguing solution.
Admin
No, no, no. You just don't have good enough compression algorithms. My project is to zip the entire contents of the universe down to a single bit which will then be tied to the state of the light switch in my office.
Light switch on = universe exists Light switch off = ...well....you don't want to know what happens when I turn the lights off!
Note to self: Leave a note for the cleaners telling them to please not turn off the lights.
Admin
All my comments look like this
x = x + 1 // add 1 to x
Admin
Yikes! I fail, left out the semi-colon
x = x + 1; // add 1 to x
Much better now.
Admin
This one gives me a bad case of the bends.
Boom, tssssh, it's the way I tell 'em.
Admin
Sorry, my mistake! I thought, for a moment, that intelligent discussion was a possibility in this forum.
Silly me.
-Name removed to protect the guilty
Admin
it does only by virtue of the windows zipped folder does a standard compression on anything dragged&dropped or copied into it.
Admin
No, the singularity doesn't occur at a 1-bit file. You only reach a singularity if, after zipping it down to one bit, you zip it One More Time.
It's at this point that the file collapses in on itself.