From 58062914fb56aa4f8e005dbd24e072251f3150b6 Mon Sep 17 00:00:00 2001
From: Amul Sul <sulamul@gmail.com>
Date: Tue, 29 Jul 2025 14:59:01 +0530
Subject: [PATCH v1 4/9] pg_waldump: Rename directory creation routine for
 generalized use.

The create_fullpage_directory() function, currently used only for
storing full-page images from WAL records, should be renamed to a more
generalized name. This would allow it to be reused in future patches
for creating other directories as needed.
---
 src/bin/pg_waldump/pg_waldump.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 8d0cd9e7156..4775275c07a 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -114,11 +114,11 @@ verify_directory(const char *directory)
 }
 
 /*
- * Create if necessary the directory storing the full-page images extracted
- * from the WAL records read.
+ * Create the directory if it doesn't exist. Report an error if creation fails
+ * or if an existing directory is not empty.
  */
 static void
-create_fullpage_directory(char *path)
+create_directory(char *path)
 {
 	int			ret;
 
@@ -1112,8 +1112,12 @@ main(int argc, char **argv)
 		}
 	}
 
+	/*
+	 * Create if necessary the directory storing the full-page images
+	 * extracted from the WAL records read.
+	 */
 	if (config.save_fullpage_path != NULL)
-		create_fullpage_directory(config.save_fullpage_path);
+		create_directory(config.save_fullpage_path);
 
 	/* parse files as start/end boundaries, extract path if not specified */
 	if (optind < argc)
-- 
2.47.1

