Jump to content

Changing (large) binary files


waldrand

Recommended Posts

If I use the Vi's "get file size" "set file size" and "set file position" I can increase or shorten the filesize.

Changes are only at the end of the file.

Is there any posibillity to do this at the startposition of a file?

It means, can I add or delete (not replace) bytes at the start position?

The size would become longer or shorter.

This makes sence for large files.

I am looking for adding or deleting an header to a large file without reading the whole file.

Link to comment

I think you will have to attack the problem by making the header(s) in a way that will allow you to place it at the end of the file (or at multiple locations..). You can see an example of this in the way the zip file format is structured.

 

I recently developed a chunk based log file format myself where the data to be logged is placed in pre-allocated (on demand) sections which each have a header that allows the readers and writers to locate the other sections (chunk headers declare its chunk size and current write position. They can also have pointers to the previous and next chunk, making it easy and quick to traverse the file structure). Another example of a chunk based file format is PNG.

 

Edited by Mads
Link to comment

What I try to to is to modify the ID3 meta data of a mp3 file.

That means I have to add same bytes before the mp3 data.

I wrote it allready, but it takes time and okkupies memory at large file.

I read the whole file added the bytes at the start and replaced the file.

I am looking for a better solution.

Link to comment

If you don't have control over the file format you may be out of luck and just have to write the whole new file.

Since you mentioned memory, have you tried writing the new header, then copying the rest of the file in chunks rather than one operation?

Link to comment

Reading the whole file and modifying it in memory is probably the only decent solution.  That being said there are a few DLLs that can be used to modify ID3 information.  Here's a few sites of which I haven't personally tried.

 

http://id3v2.sourceforge.net/

http://id3lib.sourceforge.net/

http://tomorrow.uspeoples.org/2013/02/powershell-id3-tag-editing-via-taglib.html

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.