mbed: fix rename to work correctly (newname and oldname must have the same fs)
[clinton/Smoothieware.git] / mbed / src / cpp / stdio.cpp
index 33c6ce9..1e22268 100644 (file)
@@ -305,7 +305,11 @@ extern "C" int remove(const char *path) {
 }
 
 extern "C" int rename(const char *oldname, const char *newname) {
-    return -1;
+    FilePath a(oldname);
+    FilePath b(newname);
+    if (!a.fileSystem() || a.fileSystem() != b.fileSystem()) return -1;
+
+    return a.fileSystem()->rename(a.fileName(), b.fileName());
 }
 
 extern "C" char *tmpnam(char *s) {