waldrand Posted December 28, 2015 Report Share Posted December 28, 2015 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. Quote Link to comment
Mads Posted December 29, 2015 Report Share Posted December 29, 2015 (edited) 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 December 29, 2015 by Mads Quote Link to comment
waldrand Posted December 30, 2015 Author Report Share Posted December 30, 2015 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. Quote Link to comment
mje Posted December 30, 2015 Report Share Posted December 30, 2015 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? Quote Link to comment
hooovahh Posted January 4, 2016 Report Share Posted January 4, 2016 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.