It not a joke!!! It is the truth!!!

Giving people what they want: violence and sloppy eating

Previous Entry Share Next Entry
Up to the top of the hill and back again!
mini me + poo
lovingboth
There was this video file I downloaded where the first 256 bytes were some rubbish, with the 'real file' starting immediately after.

This causes all the media players to reject it.

Hmm, if I had the spare disc space, it'd be easy - write a short Turbo Pascal program to copy file a from offset n to file b.

I don't, so I have to do it in place.

Ok, write a short TP program to do that - set i := 0 then repeat 'seek to position i+n, read n bytes, seek to position i, write them, add n to i' until you've done it all.

Quick test - yep, I managed the end conditions correctly - it worked whether or not the file was a multiple of n.

Add some code to print i each time through the loop, so I can see just how slowly it works through this nearly a gigabyte long file. I can leave it going overnight if need be...

OK, deep breath... go!

Coo, it does a million bytes a second! :)

It's quickly finished and...

... the file is still not valid :(

It looks ok in a hex viewer - you can see it was produced by nandub, for example - but obviously something's wrong.

Oh well, delete it.

?

Log in

No account? Create an account