summaryrefslogtreecommitdiff
path: root/src/port/path.c
diff options
context:
space:
mode:
authorJoe Conway <mail@joeconway.com>2016-02-17 09:12:06 -0800
committerJoe Conway <mail@joeconway.com>2016-02-17 09:12:06 -0800
commita5c43b886942e96ec5c745041f2d6a50c3205147 (patch)
treeb7d1967286366131bc65d34457fb0ba91ec710b8 /src/port/path.c
parentf1f5ec1efafe74ca45e24e0bf3371b1d6985c8ee (diff)
Add new system view, pg_config
Move and refactor the underlying code for the pg_config client application to src/common in support of sharing it with a new system information SRF called pg_config() which makes the same information available via SQL. Additionally wrap the SRF with a new system view, as called pg_config. Patch by me with extensive input and review by Michael Paquier and additional review by Alvaro Herrera.
Diffstat (limited to 'src/port/path.c')
-rw-r--r--src/port/path.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/port/path.c b/src/port/path.c
index a418f93896a..5c9de0cd331 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -172,6 +172,36 @@ make_native_path(char *filename)
/*
+ * This function cleans up the paths for use with either cmd.exe or Msys
+ * on Windows. We need them to use filenames without spaces, for which a
+ * short filename is the safest equivalent, eg:
+ * C:/Progra~1/
+ */
+void
+cleanup_path(char *path)
+{
+#ifdef WIN32
+ char *ptr;
+
+ /*
+ * GetShortPathName() will fail if the path does not exist, or short names
+ * are disabled on this file system. In both cases, we just return the
+ * original path. This is particularly useful for --sysconfdir, which
+ * might not exist.
+ */
+ GetShortPathName(path, path, MAXPGPATH - 1);
+
+ /* Replace '\' with '/' */
+ for (ptr = path; *ptr; ptr++)
+ {
+ if (*ptr == '\\')
+ *ptr = '/';
+ }
+#endif
+}
+
+
+/*
* join_path_components - join two path components, inserting a slash
*
* We omit the slash if either given component is empty.