Simple file truncation example?
Posted: Mon Dec 30, 2024 2:35 pm
Hi Everyone,
Maybe I need a coffee...but I cannot truncate a file using FatFS/POSIX or anything I can put my hands on...
Simple example of what I'm trying to achieve (assume file is 100B).
Can anyone please show simple example of how to truncate file?
Maybe I need a coffee...but I cannot truncate a file using FatFS/POSIX or anything I can put my hands on...
Simple example of what I'm trying to achieve (assume file is 100B).
Code: Select all
FILE *f = fopen(file_path, "r+");
fseek(f,-20,SEEK_END);
truncate(f,0);
fflush(f);
f_sync(f);
abort();