Re: Adding/Removing byes from the beginning of a file

new topic     » goto parent     » topic index » view thread      » older message » newer message
GreenEuphorian said...

What is the relevant command that I would use to overwrite the first few bytes?

Erm, fairly straightforward I should think:

fn = open(filename,"ub") 
if seek(fn,0)!=SEEK_OK then ?9/0 end if -- (not strictly neccessary; and SEEK_OK is automatically defined as 0 in Phix) 
puts(fn,some_bytes) 
close(fn) 

Obviously, caveat emptor, untested, expect problems if you clobber more bytes than you should, as Derek said it may make the file unusable by other apps, etc.

Pete

PS: Another (random) thought occurs to me that if you don't have enough bytes (ignore this if you do), and you really don't want to move 100s of GB, a "get first 7 bytes from file 5" type scheme might help.
PPS: It also might be sensible to blat the first few bytes, do your thing, then restore those overwritten bytes.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu