is it possible to modify files directly without creating a copy of the file ("token files").
if it is, what functions are required to perform this task?
is it possible to modify files directly without creating a copy of the file ("token files").
if it is, what functions are required to perform this task?
Yes, and the usual bunch of standard IO functions would do, depending on how you want to modify it.
Make sure you open the file in the correct mode, check this page for a list of fopen() modes. I expect you'll be wanting a binary based mode.
However, it is not possible to do things like insert a new line of text etc, as that involves shifting the data. You can only ovewrite what is already there.
If this doesn't help enough, provide a clearer example of what you're trying to do.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
um, let's say i want to modify the 100th byte of a file to "A" (65 in char).
so what i usually do is make a copy of the file in memory (part or full) and modify that in memory. afterwards, i write from memory to file. from my previous post, i just wanted to know if there was a function that can just write to the file directly instead of what i mentioned.
Well, you can directly write to the disk (at least under DOS).um, let's say i want to modify the 100th byte of a file to "A" (65 in char).
Given the information in the FAT, you have to seek the file, position to it's 100th byte, and write there what you want to.
Easy said, but not so easy to perform . You have to know exactly what you're doing, as directly accessing a disk is really dangerous.
Usually device drivers, boot loaders and viruses are using this technique.
Which one are you working on? ;°)
In real mode, BIOS's Int13h is responsible to do that:
function 02h will read sectors, 03h will write sectors.
If you're a real hacker, do not even rely on BIOS - program directly disk's HW ports (see Ralph Brown's Hardware list for details).
Have fun!
[R]evolution!
Programming related articles, downloads, demos