Again, for those who use Keil's middleware - FAT frename function has a nasty bug: if new name contains path (for example "M:\name.txt") the whole string will be used as new name. In this particular case, file will be renamed to M:\name.txt - and now it's not accesible anymore since it contains forbidden characters ':' and '\'. Behaviour is completely wrong. If the path is specified, frename should copy old file to specified destination. In my case, I've created a wrapper function that corrects this issue, which I call instead of frename.
http://www.keil.com/support/man/docs/rlarm/rlarm_frename.htm
We this would be the difference between a "file name" and a "path name", or fully qualified path.
Not sure this qualifies as a bug, the documentation seems adequate, a gotcha perhaps?
With a path name your in the realm of a file move function.
The rename() function does move a file, so the destination name may specify a path to another directory.
But are you sure that the Keil function frename() should move the file, and that it isn't just specified as renaming the file?
The documentation only mentions that the "oldname" string may specify a drive and a path.
It is up to you to care about what characters to use.
And you don't seem to have a promise in the documentation that a move to a different directory should be an expected behaviour.
Well, I do not care about move, but specifying invalid file name (containing forbidden characters) should result in returning error code instead of renaming to invalid name, don't you agree?
Sorry to dig up a 7 year old thread, but I can't get frename() to move a file to another directory. If I supply a path to a different directory/filename I get and fsInvalidPath error when I call frename(). What's the bests way to move a file?
TdeP said:I can't get frename() to move a file
Is it supposed to?
The linked documentation doesn't say that it should do a move.
no it's not supposed to, I just tried it. Seems like the only way to move a file is to open a file to move to, and fread() from the current file and fwrite() to the new file. Kind of a pain.