diff --git a/firmware/common/file.c b/firmware/common/file.c index f0437f9e68..613eba97df 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -385,9 +385,6 @@ int rename(const char* path, const char* newpath) return - 5; file = &openfiles[fd]; -#ifdef HAVE_DIRCACHE - dircache_rename(path, newpath); -#endif rc = fat_rename(&file->fatfile, &dir->fatdir, nameptr, file->size, file->attr); @@ -404,6 +401,10 @@ int rename(const char* path, const char* newpath) return rc * 10 - 7; } +#ifdef HAVE_DIRCACHE + dircache_rename(path, newpath); +#endif + rc = close(fd); if (rc<0) { errno = EIO; diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index dd0d4d650e..9dd27cf72a 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1202,6 +1202,10 @@ static int fat_checkname(const unsigned char* newname) return -1; newname++; } + /* check trailing space(s) */ + if(*(--newname) == ' ') + return -1; + return 0; }