MCPcopy Create free account
hub / github.com/derceg/explorerplusplus / DecodePath

Function DecodePath

Explorer++/Helper/ShellHelper.cpp:893–956  ·  view source on GitHub ↗

A path passed into this function may be one of the following: - A real path, either complete (e.g. C:\Windows), or relative (e.g. \Windows) - A virtual Path (e.g. ::{21EC2020-3AEA-1069-A2DD-08002B30309D} - Control Panel) - A URL (e.g. http://www.google.com.au) - A real path that is either canonicalized (i.e. contains "." or ".."), or contains embedded environments variables (i

Source from the content-addressed store, hash-verified

891 6. If the path is relative, add it onto onto the current directory
892*/
893void DecodePath(const TCHAR *szInitialPath, const TCHAR *szCurrentDirectory, TCHAR *szParsingPath,
894 size_t cchDest)
895{
896 TCHAR szExpandedPath[MAX_PATH];
897 TCHAR szCanonicalPath[MAX_PATH];
898 TCHAR szVirtualParsingPath[MAX_PATH];
899 HRESULT hr;
900 BOOL bRelative;
901 BOOL bRet;
902
903 /* If the path starts with "::", then this is a GUID for
904 a particular folder. Copy it straight to the output. */
905 if (lstrlen(szInitialPath) >= 2 && szInitialPath[0] == ':' && szInitialPath[1] == ':')
906 {
907 StringCchCopy(szParsingPath, cchDest, szInitialPath);
908 }
909 else
910 {
911 hr = DecodeFriendlyPath(
912 szInitialPath, szVirtualParsingPath, SIZEOF_ARRAY(szVirtualParsingPath));
913
914 if (SUCCEEDED(hr))
915 {
916 StringCchCopy(szParsingPath, cchDest, szVirtualParsingPath);
917 }
918 else
919 {
920 /* Attempt to expand the path (in the event that
921 it contains embedded environment variables). */
922 bRet = MyExpandEnvironmentStrings(
923 szInitialPath, szExpandedPath, SIZEOF_ARRAY(szExpandedPath));
924
925 if (!bRet)
926 {
927 StringCchCopy(szExpandedPath, SIZEOF_ARRAY(szExpandedPath), szInitialPath);
928 }
929
930 /* Canonicalizing the path will remove any "." and
931 ".." components. */
932 PathCanonicalize(szCanonicalPath, szExpandedPath);
933
934 if (PathIsURL(szCanonicalPath))
935 {
936 StringCchCopy(szParsingPath, cchDest, szCanonicalPath);
937 }
938 else
939 {
940 bRelative = PathIsRelative(szCanonicalPath);
941
942 /* If the path is relative, prepend it
943 with the current directory. */
944 if (bRelative)
945 {
946 StringCchCopy(szParsingPath, cchDest, szCurrentDirectory);
947 PathAppend(szParsingPath, szCanonicalPath);
948 }
949 else
950 {

Callers 2

OnGoMethod · 0.85

Calls 2

DecodeFriendlyPathFunction · 0.85

Tested by

no test coverage detected