Ian (lovingboth) wrote,

  • Mood:

Up to the top of the hill and back again!

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.

  • Failing as snow again, never wanted to..

    A tiny bit, but gosh, this will have been the snowiest winter in London for ages. The walk to school did help me wake up a bit (although I feel the…

  • One for Bad Science?

    Hmm, a Press Association story saying breastfeeding has almost no benefits to the baby has been picked up by the Mail and the Telegraph and... with…

  • Two recent stories

    I've forgotten to go 'hooray' here over this story from a couple of weeks ago: Food labels advice change over Palestinian territories. I am happy to…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened