745a29e59a316d5a00b33032ea5815d435312648
2 Copyright 1991-2017 Amebis
4 This file is part of atlex.
6 atlex is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
11 atlex is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with atlex. If not, see <http://www.gnu.org/licenses/>.
26 /// \defgroup ATLShellWAPI Shell API
27 /// Integrates ATL classes with Microsoft Shell API
32 /// Simplifies a path by removing navigation elements such as "." and ".." to produce a direct, well-formed path, and stores it in a ATL::CAtlStringA string.
34 /// \sa [PathCanonicalize function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb773569.aspx)
36 inline BOOL
PathCanonicalizeA(__out
ATL::CAtlStringA
&sValue
, __in LPCSTR pszPath
)
38 // Allocate buffer on heap and read into it.
39 LPSTR szBuffer
= sValue
.GetBuffer(MAX_PATH
);
41 ::SetLastError(ERROR_OUTOFMEMORY
);
44 BOOL bResult
= ::PathCanonicalizeA(szBuffer
, pszPath
);
45 sValue
.ReleaseBuffer(bResult
? (int)strnlen(szBuffer
, MAX_PATH
) : 0);
52 /// Simplifies a path by removing navigation elements such as "." and ".." to produce a direct, well-formed path, and stores it in a ATL::CAtlStringW string.
54 /// \sa [PathCanonicalize function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb773569.aspx)
56 inline BOOL
PathCanonicalizeW(__out
ATL::CAtlStringW
&sValue
, __in LPCWSTR pszPath
)
58 // Allocate buffer on heap and read into it.
59 LPWSTR szBuffer
= sValue
.GetBuffer(MAX_PATH
);
61 ::SetLastError(ERROR_OUTOFMEMORY
);
64 BOOL bResult
= ::PathCanonicalizeW(szBuffer
, pszPath
);
65 sValue
.ReleaseBuffer(bResult
? (int)wcsnlen(szBuffer
, MAX_PATH
) : 0);