Browse Source

fixed empty directory from getting created when running the stand alone version
[SAB]


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@423 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 18 năm trước cách đây
mục cha
commit
cf2931d61c
1 tập tin đã thay đổi với 10 bổ sung5 xóa
  1. 10 5
      DatabaseUtilities.cpp

+ 10 - 5
DatabaseUtilities.cpp

@@ -8,6 +8,7 @@
 #include "ProcessPaste.h"
 #include <io.h>
 #include "AccessToSqlite.h"
+#include "Path.h"
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
@@ -103,9 +104,6 @@ CString GetDefaultDBName()
 		}
 	}
 
-	if(FileExists(csDefaultPath) == FALSE)
-		CreateDirectory(csDefaultPath, NULL);
-
 	CString csTempName = csDefaultPath + "Ditto.db";
 	int i = 1;
 	while(FileExists(csTempName))
@@ -149,6 +147,13 @@ BOOL CheckDBExists(CString csDBPath)
 	{
 		csDBPath = GetDefaultDBName();
 
+		nsPath::CPath FullPath(csDBPath);
+		CString csPath = FullPath.GetPath().GetStr();
+		if(csPath.IsEmpty() == false && FileExists(csDBPath) == FALSE)
+		{
+			CreateDirectory(csPath, NULL);
+		}
+
 		// -- create a new one
 		bRet = CreateDB(csDBPath);
 	}
@@ -264,12 +269,12 @@ BOOL ValidDB(CString csPath, BOOL bUpgrade)
 	return TRUE;                                                     
 }
 
-BOOL CreateDB(CString csPath)
+BOOL CreateDB(CString csFile)
 {
 	try
 	{
 		CppSQLite3DB db;
-		db.open(csPath);
+		db.open(csFile);
 		
 		db.execDML(_T("PRAGMA auto_vacuum = 1"));