Fix file manager displays empty list when folder is deleted
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 7d896e6..aecdd25 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -302,10 +302,7 @@
 	// Fetch the file/folder list
 	std::string value;
 	DataManager::GetValue(mPathVar, value);
-	if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) {
-		GetFileList(DataManager::GetCurrentStoragePath());
-		DataManager::SetValue(mPathVar, DataManager::GetCurrentStoragePath());
-	}
+	GetFileList(value);
 }
 
 GUIFileSelector::~GUIFileSelector()
@@ -640,12 +637,7 @@
 					else
 					{
 						DataManager::SetValue(mPathVar, cwd);
-						if (GetFileList(cwd) != 0)
-						{
-							LOGE("Unable to change folders.\n");
-							DataManager::SetValue(mPathVar, oldcwd);
-							GetFileList(oldcwd);
-						}
+						GetFileList(cwd);
 						mStart = 0;
 						scrollingY = 0;
 						mUpdate = 1;
@@ -772,6 +764,17 @@
 	if (d == NULL)
 	{
 		LOGI("Unable to open '%s'\n", folder.c_str());
+		if (folder != "/" && (mShowNavFolders != 0 || mShowFiles != 0)) {
+			size_t found;
+			found = folder.find_last_of('/');
+			if (found != string::npos) {
+				string new_folder = folder.substr(0, found);
+
+				if (new_folder.length() < 2)
+					new_folder = "/";
+				DataManager::SetValue(mPathVar, new_folder);
+			}
+		}
 		return -1;
 	}
 
@@ -824,10 +827,7 @@
 	{
 		std::string value;
 		DataManager::GetValue(mPathVar, value);
-		if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) {
-			GetFileList(DataManager::GetCurrentStoragePath());
-			DataManager::SetValue(mPathVar, DataManager::GetCurrentStoragePath());
-		}
+		GetFileList(value);
 	}
 }