From a5c43b886942e96ec5c745041f2d6a50c3205147 Mon Sep 17 00:00:00 2001 From: Joe Conway Date: Wed, 17 Feb 2016 09:12:06 -0800 Subject: 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. --- src/port/path.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/port') 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 @@ -171,6 +171,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 * -- cgit v1.2.3