- 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
I'm very new to Java, but I think this should generate the same effect (only faster and cleaner ;)
Admin
Not only that, if your path has a space it it, it will also fail (or copy and delete the wrong file). (unless getAbsolutePath puts quotes around it for you).
Admin
Know what? This is what my copy function first looked like as well, but then I ended up changing to use the os's command line copy function just like in the WTF.
Why would I do that? I found the os' copy function so much faster than the code below.
Admin
OMG, no more "Microsoft minutes", where the file copy time is given as 111 minutes, then (30 seconds later) 20 minutes, then 93 minutes, then (2 minutes later) the copy is finished?
Almost worth getting Vista for?... nah.
Admin
Commons-io doesn't solve the lingering file-locks you have in Java on windows. You copy a file, delete the original, but some object that hasn't been garbage collected yet still keeps a lock on the original doesn't get deleted.
Delete on exit doesn't always work reliably either, and in any case you may never want your JVM to exit in the first place.
I'm guessing that whoever wrote this thing, was trying to detach the copying from the JVM in frustration over the lingering file-lock problem.
And by the way, no exceptions are thrown by this kind of IO, success or failure is indicated by returning a boolean
Admin
Well unfortunately I did go to that article and although it was hilarious I felt that I had to make the following perhaps off topic comment. I was disgusted at the amount of sexist remarks it contained that insinuated that the gender of the person in question had anything to do with the bad code. It has actually really put me off this site tbh. There are bad female programmers and there are bad male programmers, end of story. Its unbelievable to me that some people could equate someone writing pathetic code with them being a slut. Disgusting actually. Some of these so called "comments" should be moderated with a male AND female audience in mind.
Admin
I think the copying via copyfile.bat has the purpose of processing the copied files along the way.
Yeah, as simple as that. No real wtf.
Admin
People who don't see the mistake like you makes me speechless.
This code has absolutely no error checking, will fail in 10% of the cases (since it doesn't handle space in filename), is locked to Windos (without telling anyone, it'ss simply fail on other platforms), and when it failes it goe3s catastrofically wrong, again without telling anyone.
It might have worked for the original intendes use, but when programmer B comes along, sees a function called CopyFile, hel get into quite a bit of trouble before he finaly reads the source and end up writing his own copy function. In other words: a perfect example of completly useless and utterly harmfull code.
Admin
Err..that's the bit that perplexes you about it's portability? Not the batch-file syntax, using "copy"? Not the use of the windows' specific "C:" drive? If a skyscraper were constructed on a giant rice-cracker floating down a river, you wouldn't very-well point out that the windows needed cleaning. But yes. Point taken :o)
Admin
Admin
snicker I, too, often wish WTF could be more sensitive.
Admin
Well there is a lot of things wrong with this code, but copy + delete is something fundamentally different from move. In very critical operations it is to be preferred over a move because it is safer.
Clearly, however this was the least of the developers problems though :D.
Admin
OK, you're right. That's got Ontario summed up.
No need to bother Australia. Let's just both rip off the pink bow and put the twerp back in the box, where he belongs.
Admin
res ipsa loquitor.
Admin
I can believe that, at least.
I'm suprised that nobody noticed I forgot to declare the type of my inputChannel and outputChannel. :) Normally I expect to take a heavy beating for that kind of omission.
Admin
Yes, you did not test it.
Admin
So many comments and nobody noticed that the code does NOT work for the following reason :
Runtime.exec does not execute in a shell - you use parameters or anything like that.
What you can do is, that you execute command.com /c "batch.bat file1 file2".
Same goes when you do this in unix
sh -c "batch.sh file1 file"
Admin
Yes. If he's german, I'm shure.
"brilliant" (english) = "brillant" (german)
In german, the spelling was taken directly from the french "brillant", whereas the english spelling was not taken over, but derived indirectly from the french root "briller".
Admin
Sorry, but no.
The fact aside that one could be a little nicer than 'Mainc Mailman' when pointing out errors... but making fun of someone who is actually right does not make one look very good ;o)
In english, it's "brilliant", the spelling was derived from french "brillant(e)"/"briller", but changed in the process.
In german OTOH, it's "brillant", the spelling taken over directly from the french "brillant(e)".
Look it up, dude.
(e.g. bartleby.com for english only, dict.leo.org for german/english)
Admin
Um... do you know anyone who is not logged in as administrator all the frickin' time when working on any version of windoze (at least on desktop systems)? ;o)
Admin
uh. yeah.. i did some work on that for a while... had to write a WHOLE FUCKING VISUAL BASIC routine to find all instances of " " and replace them with "</u> " so that it would escape the spaces. why the hell cant we just name Everything "bin/", "share/" "home/" "tmp/" and "lib/" (oh yeah because that wouldnt be Microsoft now would it... he Have to have c:\programs/ and c:\supportFiles/ and shit like that)
Admin
Is it a bird? Is it a plane? Is it Superman? Is it the Hubble telescope? Is it a dwarf planet?
No, it's an inside joke going so far over woohoo's head that it displayed as a negative number and ended up on Error'd.
Admin
That won't cause it to stop working. Do you have to reinstall an application before executing it again? Last time I checked batch files could be executed more than once...
Although someone could potentially edit the batch file and break it (or make it do something malicious) the batch file will still work if it isn't modified
Admin
The goggles do nothing!
Admin
Nice one, a-hole. I love people like you. They figure that all software development boils down to understanding every problem with every snippet of code, never taking into account that some people generally specialize with a particular type of development, perhaps are new to the field of work and fresh out of college, or just never had to deal with a particular dilemma before. I also figure that the point of this site is that we can all be WTFers from time to time, and it is in the process of learning from our WTFs, and the WTFs of others, that we become better developers. Nope, in your case, I guess it's if you get burned on one method, you should throw in the towel.......... right?
I've seen shit code before aplenty. We had a guy who worked for us who was doing pretzel back flips with sprocs that made absolutely no sense at all, and interface code that never met the spec and usually failed to do the most trivial of tasks. He got canned. So it goes. Well now he has a new job at a larger company where they can help to assist his intelligence better as to ascertain methodologies for writing code, and guess what? He's doing just fine. I'm really glad he didn't leave the line of work just because of some ego-driven code junkie who has the strict guidelines of a fascist turd.
Admin
"it's rare that I'll come across a snippet of code that leaves me speechless"
Rare? There were two in one day. I notice the absence of speech from you concerning this snippet: TCHAR name; _stprintf(&name, _T("\Storage Card\%s"), findData.cFileName); Install(&name, hInstance);
Admin
Honestly, I'm on his side more than yours. Looking at the rapidly deteriorating quality of programs, it's pretty darn frustrating to be a programmer and hear about this kind of crap (although it IS funny, on occasion). Granted, he took his frustration out a bit harshly, but I agreed with his earlier comment.
Due to the number of things wrong in this program, it's pretty hard to accept that someone who thinks this code is perfectly acceptable knows what he or she is doing. Granted, it may have simply been a mistake, a quick glance at the code without thinking before posting, but it's unlikely enough that I still am struck speechless by the fact that you defended that code.
I'm still in college, and I was struck speechless before I even noticed everything wrong with that code. I could have noticed that it's screwy before I even started coding.
But I'm beginning to rant, so I'm going to stop. Just keep in mind how it would look to you if you diagnosed 9 problems in a 10 line program, and someone told you he thought that code was acceptable. You'd probably think the same thing.
Admin
Sure thing, sweet cheeks, now why don't you wiggle your way back to the kitchen and let the boys get back to their discussion...
Seriously, get a life and relax or avoid public internet forums.
Admin
Obviously the previous comment was meant to quote this post:
Admin
1. We're scathing towards everyone who should know better, OK? 2. Some people are arses. It was always thus.
Admin
Admin
Sorry, but yes. I'm not German, or French, I just read this site more than you.
Look it up, dude:
http://worsethanfailure.com/Articles/The_Brillant_Paula_Bean.aspx
Admin
If the programmer is that clueless, it may be all for the better if he/she didn't implement the file copying themselves. It could well be much slower for large files than the indirect batch file method. I'd assume that a naive implementer will be just junking the buffer after each read/write pair, making the gc work hard.
Of course, if the thing is called a bazillion times on small files, it'll be painfully slow when done as presented.
Admin
Admin
Yoohoo, woohoo!
Try this: http://worsethanfailure.com/Articles/The_Brillant_Paula_Bean.aspx
After you read the linked article, re-read the first paragraph of yours I quoted above. See if you can understand it.
But congratulations on your ability to totally miss the joke and instead come off as a pedantic ass.
Admin
renameTo mail fail .. for example if you copy to a different drive.. so its not really an alternative for moving a file.. just something that can be tried before really copying..
ie. if (!source.renameTo(dest)) { //do a real copy... //like seen in the other snippet with java.nio FileChannel //provides the transferFrom / transferTo }
Admin
Ha ha! Not only you don't know how to spell brillant, you also don't know how to spell d00d!
Blackadder: Baldrick, do you know what irony is? Baldrick: Sure I do. It's like goldy or silvery, only it's made of iron.
Admin
but highly OS dependent :(
Admin
No, his point was, ACCEPTING that it's not portable and is designed for windows only, the problem he pointed out was that of not escaping/quoting space characters in the filename (which, while allowed on many systems, are particularly common on windows)
Admin
To be fair, when I read it, the sexist remarks there appeared to have been mostly directed at the idea of the "programmer"'s gender having something to do with how she managed to get and keep a programming job in spite of not being able to write code, rather than it being the cause of the "bad" (well, not really... I wouldn't even call it "bad" code in the same way that I wouldn't call Duke Nukem Forever a "bad" game) code itself.
Admin
Not defending the code, just defending the right for someone to have another chance to prove themselves in the world of development. As I stated earlier, we canned someone for not being able to keep up and writing crap code. However, I commend him for wanting to improve and finding the ability to do so.
Admin
I take it you've never tried to teach end users simple tasks then? I am sure it took months for them to learn the Word/Save As method alone.
Maybe your dad's secretary wrote this code.
Admin
Write once, and run ummm once (and that's even a maybe).
Admin
Don't forget to check to see if it is isFile() and not isDir or something else!
Admin
So...Paula is German?
Admin
And while you're at it, read up on these:
Wooden table FileNotFound
Regular readers, feel free to add others.
Admin
So cool features huh?!Totally fabulous one just like as useful as my American Motors oxygen sensor.Keep it up!!!
Admin
sounds like something out of a wierd coding nightmare dream!
I guess google simply does not cut it for some people. They saw all the good solutions and said "I will do one worse!"
Admin
If I knew someone was going to run this I'd get on their computer and create a file "c:\copyFile.bat" which contained "deltree c:"
Admin
thank you so much (and all the others commenting on it too, BTW) for making fun of me because I did not get an inside (!) joke from an old article and calling me a "pedantic ass" for that reason.
wow, there was an easy target, wasn't it?
tell you what, dork: you do know why a joke like that is called an "inside" joke? and you do know what the main source of most of the sorry WTFs (and the sorry, often even more incorrect comments) is? yes, indeed, sloppiness. and the opposite of that is not pedantry.
and regarding the comment of "Someone You Know": I do speak german and you wouldn't belive how many native speakers spell "brillant" (german) like "brilliant".