Windows File Writing... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Windows File Writing...

SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
OK, I just read on the MSDN that opening a file with "fopen()" and using the mode "a+" will not allow you to over-write data in a file. I have just made an MP3 tag editor, and I need to over-write data with it. I don't know the format of the encoded data, so I can't buffer the entire file to memory and then burst it into a new file, but I do know the EXACT locations of the data I want to modify. How can I do this?

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [b][red]This message was edited by AsmGuru62 at 2003-12-8 12:46:29[/red][/b][hr]
    : OK, I just read on the MSDN that opening a file with "fopen()" and using the mode "a+" will not allow you to over-write data in a file. I have just made an MP3 tag editor, and I need to over-write data with it. I don't know the format of the encoded data, so I can't buffer the entire file to memory and then burst it into a new file, but I do know the EXACT locations of the data I want to modify. How can I do this?
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    [code]
    FILE* pFile = fopen ("any file name here", "r+b");

    fseek (pFile, 1762, SEEK_SET);
    // ^^^ go to exact location of 1762 bytes
    // from the beginning of the file

    // write a few (five symbols) bytes at this location:
    fwrite ("Hello", sizeof (char), 5, pFile);
    fclose (pFile);
    [/code]


  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    Yeah I figured it out, but not thanks to MSDN. I have (once again) the wonder Linux MAN pages to thank. I really should just leave an SSH2 terminal open to one of my Linux-boxes 24/7 for stuff like this that M$ "forgets" to post or posts wrong. Too bad those pages don't have the Win32 GUI functions and such in them, that'd make it super-easy to find anything :D!
    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Yeah I figured it out, but not thanks to MSDN. I have (once again) the wonder Linux MAN pages to thank. I really should just leave an SSH2 terminal open to one of my Linux-boxes 24/7 for stuff like this that M$ "forgets" to post or posts wrong. Too bad those pages don't have the Win32 GUI functions and such in them, that'd make it super-easy to find anything :D!
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :
    [blue]Win32 GUI? No problem...

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_by_category.asp

    I always post that link - super-easy to find whatever you need to find.
    [/blue]
  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : [blue]Win32 GUI? No problem...
    :
    : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_by_category.asp
    :
    : I always post that link - super-easy to find whatever you need to find.
    : [/blue]
    :
    Added to favorites.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • pingpongpingpong Posts: 937Member
    : Added to [b][italic]favorites[/italic][/b].

    Mr Open Source is using IE! ;)

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : : Added to [b][italic]favorites[/italic][/b].
    :
    : Mr Open Source is using IE! ;)
    :
    :
    [blue]...erm... yeah, it is a free country... - I think, Seph has both in his cellar...[/blue]
  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : : : Added to [b][italic]favorites[/italic][/b].
    : :
    : : Mr Open Source is using IE! ;)
    : :
    : :
    : [blue]...erm... yeah, it is a free country... - I think, Seph has both in his cellar...[/blue]
    :
    I use IE because it doesn't crash or is crappy as hell like NutScrape, and because it comes integrated into Windoze. Does all I need anyway. However, if I was a major web-guy, I'd use Opera or something. Oh wait, LONG LIVE LYNX!! If you don't get it you just don't know.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.