is the rename function broken?
I call "rename(/fs/old, /fs/new);" however the code is never executed and "-1" is always returned. The rename is called on a FileFystemLike child class object called FS instantiated with the name "filesys". The rename function is defined in this child class and should be executed when the wrapper function is called, however the code is completely skipped and -1 is returned.
This way of defining virtual functions in the child class and calling them with wrapper functions works with open, opendir, remove, etc. but not rename. Is there something I overlooked or does anyone know why?
some code:
#include "fschild.h"
int main
{
fschild FS("filesys");
FILE *fp = fopen("/filesys/test.txt", "w");
fprintf(fp, "Hello, World!");
fclose(fp);
//remove("/filesys/test.txt"); it works
//rename("/filesys/test.txt", "/filesys/test2.txt"); it returns -1 always
}
snippet from mbed FileSystemLike.h
class FileSystemLike : public Base {
public:
/* Function remove
* Remove a file from the filesystem.
*
* Variables
* filename - the name of the file to remove.
* returns - 0 on success, -1 on failure.
*/
virtual int remove(const char *filename) { return -1; };
/* Function rename
* Rename a file in the filesystem.
*
* Variables
* oldname - the name of the file to rename.
* newname - the name to rename it to.
* returns - 0 on success, -1 on failure.
*/
virtual int rename(const char *oldname, const char *newname) { return -1; };
}
snippets from my code:
class fschild : public FileSystemLike
{
public:
fschild(const char* SystemName);
virtual FileHandle* open(const char* filename, int flags);
virtual int remove(const char* filename);
virtual int rename(const char* oldname, const char* newname);
}
int fschild::remove(const char* filename)
{
char FileName[64];
sprintf(FileName, "%d:/%s", Drive, filename);
if (f_unlink((const TCHAR*)FileName))
{
return -1;
}
else
{
return 0;
}
}
int fschild::rename(const char* oldname, const char* newname)
{
char OldName[64];
sprintf(OldName, "%d:/%s", Drive, oldname);
if (f_rename((const TCHAR*)OldName, (const TCHAR*)newname))
{
return -1;
}
else
{
return 0;
}
}
@ Simon, I'm almost done getting full functionality from the FAT File System, this is the last bug! Let me know how you would like to be credited for your work, right now I am only keeping your old comments at the top. Thanks again for all of the help, the FATFileSystem has indeed become very useful.
is the rename function broken?
I call "rename(/fs/old, /fs/new);" however the code is never executed and "-1" is always returned. The rename is called on a FileFystemLike child class object called FS instantiated with the name "filesys". The rename function is defined in this child class and should be executed when the wrapper function is called, however the code is completely skipped and -1 is returned.
This way of defining virtual functions in the child class and calling them with wrapper functions works with open, opendir, remove, etc. but not rename. Is there something I overlooked or does anyone know why?
some code:
snippet from mbed FileSystemLike.h
snippets from my code:
@ Simon, I'm almost done getting full functionality from the FAT File System, this is the last bug! Let me know how you would like to be credited for your work, right now I am only keeping your old comments at the top. Thanks again for all of the help, the FATFileSystem has indeed become very useful.