浏览代码

re create the database at the same location if the original was deleted

scott brogden 7 年之前
父节点
当前提交
9bcae2d5aa
共有 1 个文件被更改,包括 16 次插入8 次删除
  1. 16 8
      DatabaseUtilities.cpp

+ 16 - 8
DatabaseUtilities.cpp

@@ -103,17 +103,25 @@ BOOL CheckDBExists(CString csDBPath)
 	BOOL bRet = FALSE;
 	if(FileExists(csDBPath) == FALSE)
 	{
-		csDBPath = GetDefaultDBName();
+		//first try and create create a db at the same path that was selectd
+		bRet = CreateDB(csDBPath);
 
-		nsPath::CPath FullPath(csDBPath);
-		CString csPath = FullPath.GetPath().GetStr();
-		if(csPath.IsEmpty() == false && FileExists(csDBPath) == FALSE)
+		//if that didn't work then go back to the default location
+		if (FileExists(csDBPath) == FALSE)
 		{
-			CreateDirectory(csPath, NULL);
-		}
+			csDBPath = GetDefaultDBName();
 
-		// -- create a new one
-		bRet = CreateDB(csDBPath);
+			nsPath::CPath FullPath(csDBPath);
+			CString csPath = FullPath.GetPath().GetStr();
+			if (csPath.IsEmpty() == false && FileExists(csDBPath) == FALSE)
+			{
+				CreateDirectory(csPath, NULL);
+			}
+
+			CGetSetOptions::SetDBPath(csDBPath);
+
+			bRet = CreateDB(csDBPath);
+		}
 	}
 	else
 	{