-
Couldn't load subscription status.
- Fork 4.9k
Fix for get_folder_path #9562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix for get_folder_path #9562
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b20efa1
Use SHGetFolderPath instead of SHGetKnownFolderPath on get_folder_path.
aangerma a6b15ab
CR fixes
aangerma 1b0ad99
Move h_result check to utilities
aangerma 4e65276
CR fixes
aangerma 637b843
Fixed linkage issues.
aangerma 1b33e8d
Fixes
aangerma accee5a
More fixes
aangerma 83f85a9
Fix Linux issue
aangerma 9cfa3bd
CR fixes
aangerma 86fc72c
fix
aangerma a2b2bb1
CR fixes
aangerma bda30bf
fixes
aangerma 53a3a27
Fixes
aangerma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # License: Apache 2.0. See LICENSE file in root directory. | ||
| # Copyright(c) 2021 Intel Corporation. All Rights Reserved. | ||
|
|
||
| if(WIN32) | ||
| target_sources(${LRS_TARGET} | ||
| PRIVATE | ||
| "${CMAKE_CURRENT_LIST_DIR}/hresult.h") | ||
|
|
||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // License: Apache 2.0. See LICENSE file in root directory. | ||
| // Copyright(c) 2021 Intel Corporation. All Rights Reserved. | ||
|
|
||
| #pragma once | ||
| #include <string> | ||
| #include <Windows.h> | ||
| #include <functional> | ||
| #include <comdef.h> | ||
| #include <sstream> | ||
| #include "../string/windows/windows.h" | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| namespace utilities { | ||
| namespace hresult { | ||
|
|
||
| inline std::string hr_to_string(HRESULT hr) | ||
| { | ||
| _com_error err(hr); | ||
| std::wstring errorMessage = (err.ErrorMessage()) ? err.ErrorMessage() : L""; | ||
| std::ostringstream ss; | ||
| ss << "HResult 0x" << std::hex << hr << ": \"" << string::windows::win_to_utf(errorMessage.data()) << "\""; | ||
| return ss.str(); | ||
| } | ||
|
|
||
|
|
||
| #define CHECK_HR_STR_THROW( call, hr ) \ | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if( FAILED( hr ) ) \ | ||
| { \ | ||
| std::stringstream ss; \ | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ss << call << " returned: " << utilities::hresult::hr_to_string( hr ); \ | ||
| std::string descr = ss.str(); \ | ||
| throw std::runtime_error( descr ); \ | ||
| } | ||
|
|
||
| #if BUILD_EASYLOGGINGPP | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #define CHECK_HR_STR_LOG( call, hr ) \ | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if( FAILED( hr ) ) \ | ||
| { \ | ||
| std::stringstream ss; \ | ||
| ss << call << " returned: " << utilities::hresult::hr_to_string( hr ); \ | ||
| std::string descr = ss.str(); \ | ||
| LOG_DEBUG(descr); \ | ||
| } | ||
| #endif | ||
|
|
||
| #define CHECK_HR( x ) CHECK_HR_STR_THROW( #x, x ) | ||
|
|
||
| #if BUILD_EASYLOGGINGPP | ||
| #define LOG_HR( x ) CHECK_HR_STR_LOG( #x, x ) | ||
| #endif | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // License: Apache 2.0. See LICENSE file in root directory. | ||
| // Copyright(c) 2021 Intel Corporation. All Rights Reserved. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <algorithm> | ||
| #include <string> | ||
| #include <sstream> | ||
|
|
||
| #ifdef WIN32 | ||
| #include <Windows.h> | ||
|
|
||
| namespace utilities { | ||
| namespace string { | ||
| namespace windows | ||
| { | ||
|
|
||
| inline std::string win_to_utf(const WCHAR * s) | ||
| { | ||
| auto len = WideCharToMultiByte(CP_UTF8, 0, s, -1, nullptr, 0, nullptr, nullptr); | ||
| std::stringstream ss; | ||
|
|
||
| if (len == 0) | ||
| { | ||
| ss << "WideCharToMultiByte(...) returned 0 and GetLastError() is " << GetLastError(); | ||
| throw std::runtime_error(ss.str()); | ||
| } | ||
|
|
||
| std::string buffer(len - 1, ' '); | ||
| len = WideCharToMultiByte(CP_UTF8, 0, s, -1, &buffer[0], static_cast<int>(buffer.size()) + 1, nullptr, nullptr); | ||
| if (len == 0) | ||
| { | ||
| ss.clear(); | ||
| ss << "WideCharToMultiByte(...) returned 0 and GetLastError() is " << GetLastError(); | ||
| throw std::runtime_error(ss.str()); | ||
| } | ||
|
|
||
| return buffer; | ||
| } | ||
| #endif | ||
|
|
||
| } //windows | ||
maloel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } // namespace string | ||
| } // namespace utilities | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.