From c73a6a410231724f62adb71f915499f45a635e53 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 10 Feb 2015 09:04:45 +0100 Subject: [PATCH] mbed: fix rename to work correctly (newname and oldname must have the same fs) * Fixes rename problem in #597 * Is this a change to the mbed library? Maybe this should go upstream? See #598 --- mbed/src/cpp/stdio.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mbed/src/cpp/stdio.cpp b/mbed/src/cpp/stdio.cpp index cd0a97ee1d..1e22268332 100644 --- a/mbed/src/cpp/stdio.cpp +++ b/mbed/src/cpp/stdio.cpp @@ -305,11 +305,11 @@ extern "C" int remove(const char *path) { } extern "C" int rename(const char *oldname, const char *newname) { - FilePath fp(oldname); - FileSystemLike *fs = fp.fileSystem(); - if (fs == NULL) return -1; + FilePath a(oldname); + FilePath b(newname); + if (!a.fileSystem() || a.fileSystem() != b.fileSystem()) return -1; - return fs->rename(fp.fileName(), newname); + return a.fileSystem()->rename(a.fileName(), b.fileName()); } extern "C" char *tmpnam(char *s) {