gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > renaming files...

#151582 - darkchild - Fri Feb 29, 2008 10:13 pm

hi, This is my first post (yay)

and I'm sorry for my first post being asking for help :(

but well it's like this:

I am trying to rename a file...

But am unable to.

I am using the "rename" function and the official libfat from DevKitARM
but it keeps returning -1 (which means that something went wrong)

Can you guys help me?

I mean, I tried everything, from changing the source file and new file over and over, using "fat1:" in the beginning of the path...everything

Please, my project (iFile) depends on it :(

#151584 - tepples - Fri Feb 29, 2008 10:27 pm

darkchild wrote:
I am using the "rename" function and the official libfat from DevKitARM
but it keeps returning -1 (which means that something went wrong)

Can you guys help me?

Last time I checked, rename() was broken. Workarounds exist:
  1. Remove the SD card from the DS and use a PC to rename files.
  2. Copy the file and delete the old one.

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#151585 - darkchild - Fri Feb 29, 2008 10:46 pm

and can you give me a code sample?

because I don't know how to.

I searched code snippets and none worked :X

#151602 - darkchild - Sat Mar 01, 2008 4:16 am

sorry for double posting but...
can't I just use an older Libfat? :O

#152460 - no2pencil - Sun Mar 16, 2008 10:47 am

Couldn't you simply copy the file & destroy the original? That would basically be the same as renaming it.
_________________
-#2pencil

#152488 - tepples - Sun Mar 16, 2008 5:32 pm

no2pencil wrote:
Couldn't you simply copy the file & destroy the original? That would basically be the same as renaming it.

How would you check for enough space on the card to make the copy, especially if you are trying to rename a folder?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#152517 - no2pencil - Mon Mar 17, 2008 2:12 am

tepples wrote:
no2pencil wrote:
Couldn't you simply copy the file & destroy the original? That would basically be the same as renaming it.

How would you check for enough space on the card to make the copy, especially if you are trying to rename a folder?

To rename a folder, create a new folder, move the contents into the new one & remove the old one. You could file in & file out one at a time.

I'm just throwing suggestions out for discussion...
_________________
-#2pencil