From a6b3b55eb9c1f4760ec014bd0456adaeffd6c009 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 22 Sep 2017 18:04:31 -0500 Subject: [PATCH] fs: Fix dir open during failure condition Should leave the Dir in an openable state, currently does not since it thinks it's in use by the fs it failed to open on. --- features/filesystem/Dir.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/features/filesystem/Dir.cpp b/features/filesystem/Dir.cpp index 867105b96a..17014e3bae 100644 --- a/features/filesystem/Dir.cpp +++ b/features/filesystem/Dir.cpp @@ -43,8 +43,12 @@ int Dir::open(FileSystem *fs, const char *path) return -EINVAL; } - _fs = fs; - return _fs->dir_open(&_dir, path); + int err = fs->dir_open(&_dir, path); + if (!err) { + _fs = fs; + } + + return err; } int Dir::close()