WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Shell.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 1991-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
12
13#pragma once
14
15#include "Common.h"
16#include <Shlwapi.h>
17#include <string>
18
21
23template<class _Traits, class _Ax>
24static BOOL PathCanonicalizeA(_Inout_ std::basic_string<char, _Traits, _Ax> &sValue, _In_ LPCSTR pszPath)
25{
26 assert(0); // TODO: Test this code.
27
28 // Allocate buffer on heap and read into it.
29 char szBuffer[MAX_PATH + 1];
30 BOOL bResult = ::PathCanonicalizeA(szBuffer, pszPath);
31 sValue.assign(szBuffer, bResult ? MAX_PATH : 0);
32 return bResult;
33}
34
40template<class _Traits, class _Ax>
41static BOOL PathCanonicalizeW(_Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue, _In_ LPCWSTR pszPath)
42{
43 assert(0); // TODO: Test this code.
44
45 wchar_t szBuffer[MAX_PATH + 1];
46 BOOL bResult = ::PathCanonicalizeW(szBuffer, pszPath);
47 sValue.assign(szBuffer, bResult ? MAX_PATH : 0);
48 return bResult;
49}
50
General API.
static BOOL PathCanonicalizeW(std::basic_string< wchar_t, _Traits, _Ax > &sValue, LPCWSTR pszPath)
Simplifies a path by removing navigation elements such as "." and ".." to produce a direct,...
Definition: Shell.h:41
static BOOL PathCanonicalizeA(std::basic_string< char, _Traits, _Ax > &sValue, LPCSTR pszPath)
Simplifies a path by removing navigation elements such as "." and ".." to produce a direct,...
Definition: Shell.h:24