Can't get (f)truncate working

Post Reply
hamm
Posts: 2
Joined: Fri Aug 21, 2009 2:20 pm

Can't get (f)truncate working

Post by hamm » Fri Aug 21, 2009 2:34 pm

I want to reduce the size of a file without copying and tried the following.

Code: Select all

#include <nds.h>
#include <fat.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {

fatInitDefault();
truncate("test.dat", 123);

while(1) {
      swiWaitForVBlank();
   }

   return 0;
} 
I also added -lfat in LIBS.

The problem is the filesize is the same like before after running the code.
Can anybody help me please?

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: Can't get (f)truncate working

Post by Sylus101 » Fri Aug 21, 2009 4:20 pm

I honestly don't know anything about that function... so I'm shooting in the dark here.

Did you test on hardware? That wouldn't work with an emulator.

Do you have to have opened the file perhaps first?
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

hamm
Posts: 2
Joined: Fri Aug 21, 2009 2:20 pm

Re: Can't get (f)truncate working

Post by hamm » Fri Aug 21, 2009 5:35 pm

I tested it directly on the dsl hardware.

It's not necessary to open the file before. I tested it but it doesn't change anything.

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: Can't get (f)truncate working

Post by elhobbs » Fri Aug 21, 2009 7:40 pm

if you are using ftruncate then may also need to use fsync to commit the changes to disk. didn't test this myself though...

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests