[Groonga-commit] pgroonga/pgroonga at d47839f [master] check: may support Windows

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 4 22:04:42 JST 2017


Kouhei Sutou	2017-01-04 22:04:42 +0900 (Wed, 04 Jan 2017)

  New Revision: d47839f8ac1d434dfc1b5ca987f9e68c6672a7c8
  https://github.com/pgroonga/pgroonga/commit/d47839f8ac1d434dfc1b5ca987f9e68c6672a7c8

  Message:
    check: may support Windows

  Modified files:
    src/pgroonga-check.c

  Modified: src/pgroonga-check.c (+29 -15)
===================================================================
--- src/pgroonga-check.c    2017-01-04 22:04:19 +0900 (eb3a2e8)
+++ src/pgroonga-check.c    2017-01-04 22:04:42 +0900 (9e28cc9)
@@ -26,21 +26,22 @@ PGrnRemoveAllRelatedFiles(const char *databaseDirectoryPath)
 {
 #ifdef WIN32
 	WIN32_FIND_DATA data;
-	HANDLE finder = FindFirstFile(databaseDirectoryPath, &data);
+	HANDLE finder;
+	char targetPath[MAXPGPATH];
+
+	join_path_components(targetPath,
+						 databaseDirectoryPath,
+						 PGrnDatabaseBasename "*");
+	finder = FindFirstFile(targetPath, &data);
 	if (finder != INVALID_HANDLE_VALUE)
 	{
 		do
 		{
-			char targetPathPrefix[MAXPGPATH];
-			join_path_components(targetPathPrefix,
+			char path[MAXPGPATH];
+			join_path_components(path,
 								 databaseDirectoryPath,
-								 PGrnDatabaseBasename);
-			if (strncmp(data.cFileName,
-						targetPathPrefix,
-						strlen(targetPathPrefix)) == 0)
-			{
-				unlink(data.cFileName);
-			}
+								 data.cFileName);
+			unlink(data.cFileName);
 		} while (FindNextFile(finder, &data) != 0);
 		FindClose(finder);
 	}
@@ -96,21 +97,34 @@ PGrnCheckDatabaseDirectory(grn_ctx *ctx, const char *databaseDirectoryPath)
 static void
 PGrnCheck(grn_ctx *ctx)
 {
-	/* TODO: Support table space: "pg_tblspc/" */
 	const char *baseDirectoryPath = "base";
 
 #ifdef WIN32
 	WIN32_FIND_DATA data;
-	HANDLE finder = FindFirstFile(baseDirectoryPath, &data);
+	HANDLE finder;
+	char targetPath[MAXPGPATH];
+
+	join_path_components(targetPath,
+						 baseDirectoryPath,
+						 "*");
+	finder = FindFirstFile(targetPath, &data);
 	if (finder != INVALID_HANDLE_VALUE)
 	{
 		do
 		{
+			char databaseDirectoryPath[MAXPGPATH];
+
+			if (strcmp(data.cFileName, ".") == 0)
+				continue;
+			if (strcmp(data.cFileName, "..") == 0)
+				continue;
 			if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-			{
 				continue;
-			}
-			PGrnCheckDatabaseDirectory(ctx, data.cFileName);
+
+			join_path_components(databaseDirectoryPath,
+								 baseDirectoryPath,
+								 data.cFileName);
+			PGrnCheckDatabaseDirectory(ctx, databaseDirectoryPath);
 		} while (FindNextFile(finder, &data) != 0);
 		FindClose(finder);
 	}
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index