Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 85310)
+++ /trunk/include/iprt/mangling.h	(revision 85311)
@@ -1680,4 +1680,6 @@
 # define RTPathFilenameEx                               RT_MANGLER(RTPathFilenameEx)
 # define RTPathFilenameExUtf16                          RT_MANGLER(RTPathFilenameExUtf16)
+# define RTPathFindCommon                               RT_MANGLER(RTPathFindCommon)
+# define RTPathFindCommonEx                             RT_MANGLER(RTPathFindCommonEx)
 # define RTPathGetCurrent                               RT_MANGLER(RTPathGetCurrent)
 # define RTPathGetCurrentDrive                          RT_MANGLER(RTPathGetCurrentDrive)
Index: /trunk/include/iprt/path.h
===================================================================
--- /trunk/include/iprt/path.h	(revision 85310)
+++ /trunk/include/iprt/path.h	(revision 85311)
@@ -519,4 +519,29 @@
 RTDECL(char *) RTPathFilenameEx(const char *pszPath, uint32_t fFlags);
 RTDECL(PRTUTF16) RTPathFilenameExUtf16(PCRTUTF16 pwszPath, uint32_t fFlags);
+
+/**
+ * Finds the common path in a given set of paths, extended version.
+ *
+ * Note: This does not check paths for existience or other things (e.g. symlinks).
+ *
+ * @returns Length (in characters) of the common path, 0 if not found.
+ * @param   papcszPaths         Array of paths to find common path for.
+ * @param   cPaths              Number of paths in \a papcszPaths.
+ * @param   szSeparator         Path separator to use for comparision.
+ */
+RTDECL(size_t) RTPathFindCommonEx(const char * const *papcszPaths, size_t cPaths, char szSeparator);
+
+/**
+ * Finds the common path in a given set of paths.
+ *
+ * Uses the system's native slash as separator.
+ * Note: This does not check paths for existience or other things (e.g. symlinks).
+ *
+ * @returns Length (in characters) of the common path, 0 if not found.
+ * @param   papcszPaths         Array of paths to find common path for.
+ * @param   cPaths              Number of paths in \a papcszPaths.
+ * @param   szSeparator         Path separator to use for comparision.
+ */
+RTDECL(size_t) RTPathFindCommon(const char * const *papcszPaths, size_t cPaths);
 
 /**
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 85310)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 85311)
@@ -548,4 +548,5 @@
 	common/path/RTPathFilename.cpp \
 	common/path/RTPathFilenameUtf16.cpp \
+	common/path/RTPathFindCommon.cpp \
 	common/path/RTPathGlob.cpp \
 	common/path/RTPathHasExt.cpp \
Index: /trunk/src/VBox/Runtime/common/path/RTPathFindCommon.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/path/RTPathFindCommon.cpp	(revision 85311)
+++ /trunk/src/VBox/Runtime/common/path/RTPathFindCommon.cpp	(revision 85311)
@@ -0,0 +1,73 @@
+/* $Id$ */
+/** @file
+ * IPRT - RTPathFindCommon implementations.
+ */
+
+/*
+ * Copyright (C) 2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include "internal/iprt.h"
+#include <iprt/assert.h>
+#include <iprt/errcore.h>
+#include <iprt/path.h>
+
+
+RTDECL(size_t) RTPathFindCommonEx(const char * const *papcszPaths, size_t cPaths, char szSeparator)
+{
+    AssertPtrReturn(papcszPaths, 0);
+    AssertReturn(cPaths, 0);
+    AssertReturn(szSeparator != '\0', 0);
+
+    const char *pcszRef = papcszPaths[0]; /* The reference we're comparing with. */
+
+    size_t cch = 0;
+    do
+    {
+        for (size_t i = 0; i < cPaths; ++i)
+        {
+            const char *pcszPath = papcszPaths[i];
+            if (   pcszPath[cch]
+                && pcszPath[cch] == pcszRef[cch])
+                continue;
+
+            while (   cch
+                   && pcszRef[--cch] != szSeparator) { }
+
+            return cch ? cch + 1 : 0;
+        }
+    }
+    while (++cch);
+
+    return 0;
+}
+RT_EXPORT_SYMBOL(RTPathFindCommonEx);
+
+
+RTDECL(size_t) RTPathFindCommon(const char * const *papcszPaths, size_t cPaths)
+{
+    return RTPathFindCommonEx(papcszPaths, cPaths, RTPATH_SLASH);
+}
+RT_EXPORT_SYMBOL(RTPathFindCommon);
+
Index: /trunk/src/VBox/Runtime/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 85310)
+++ /trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 85311)
@@ -101,4 +101,5 @@
 	tstOnce \
 	tstRTPath \
+	tstRTPathFindCommon \
 	tstRTPathGlob \
 	tstRTPathQueryInfo \
@@ -569,4 +570,7 @@
 tstRTPath_SOURCES = tstRTPath.cpp
 
+tstRTPathFindCommon_TEMPLATE = VBOXR3TSTEXE
+tstRTPathFindCommon_SOURCES = tstRTPathFindCommon.cpp
+
 tstRTPathGlob_TEMPLATE = VBOXR3TSTEXE
 tstRTPathGlob_SOURCES = tstRTPathGlob.cpp
Index: /trunk/src/VBox/Runtime/testcase/tstRTPathFindCommon.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstRTPathFindCommon.cpp	(revision 85311)
+++ /trunk/src/VBox/Runtime/testcase/tstRTPathFindCommon.cpp	(revision 85311)
@@ -0,0 +1,78 @@
+/* $Id$ */
+/** @file
+ * IPRT Testcase - String splitting.
+ */
+
+/*
+ * Copyright (C) 2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include <iprt/path.h>
+
+#include <iprt/test.h>
+#include <iprt/stream.h>
+#include <iprt/string.h>
+
+
+int main()
+{
+    RTTEST hTest;
+    int rc = RTTestInitAndCreate("tstRTPathFindCommon", &hTest);
+    if (rc)
+        return rc;
+    RTTestBanner(hTest);
+
+    struct
+    {
+        char  *papszPath1;
+        char  *papszPath2;
+        char  *papszPath3;
+        char  *papszPatCommon;
+    } aTests[] =
+    {
+        /* Simple stuff first. */
+        { "", "", "", "" },
+        { "none", "none", "", "" },
+        /* Missing start slash. */
+        { "/path/to/stuff1", "path/to/stuff2", "", "" },
+        /* Working stuff. */
+        { "/path/to/stuff1", "/path/to/stuff2", "/path/to/stuff3", "/path/to/" },
+        { "/path/to/stuff1", "/path/to/", "/path/", "/path/" },
+        { "/path/to/stuff1", "/", "/path/", "" },
+        { "/path/to/../stuff1", "./../", "/path/to/stuff2/..", "" }
+    };
+
+    const size_t cNumPaths = 3; /* Number of paths to compare. */
+
+    size_t cchRes;
+    for (size_t i = 0; i < RT_ELEMENTS(aTests); i++)
+        RTTEST_CHECK_MSG(hTest, (cchRes = RTPathFindCommonEx((const char * const *)&aTests[i], cNumPaths, '/')) == strlen(aTests[i].papszPatCommon),
+                         (hTest, "Test %zu failed: Got %zu, expected %zu\n", i, cchRes, strlen(aTests[i].papszPatCommon)));
+
+    /*
+     * Summary.
+     */
+    return RTTestSummaryAndDestroy(hTest);
+}
+
