win-api: Switch Windows -A apis to -W variants - #13810
Open
Dankirk wants to merge 8 commits into
Open
Conversation
Match GetAppConfigPathPtr and os_get_path_ptr_internal file path formatting with GetAppConfigPath and os_get_path_internal. Empty/null strings return base path. Remove arbitrary path length limit with dynamic allocation.
Use dynamically allocated paths instead of arbitrary static allocations, that may not be fit long paths on all OSs. Filepaths from Windows W apis get stored internally in UTF-8, which may increase the bytes needed. Changed some A api calls to W variants to support longer paths, and to get them in supported encoding isntead of ansi code page. Fix overflow in os_stat() when used with long filename. Fix off-by-one length check in nvvfx-load sdk path.
Define FILENAME_MAX_LENGTH_UTF8 (_MAX_PATH * 3) for storing utf-16 converted paths in utf-8 on Windows for cases where dynamic allocation could may be performance issue and for simplicity. A UTF-16 code unit (wchar_t) can be up to 3 bytes/chars in UTF-8. Change os_dirent filename to be char pointer, so it is OS agnostic about the actual allocation size. It is also compiled in to lua/python wraps, so we can't use platform specific defines.
Use W apis instead of A apis and as necessary convert to utf-8 only from it to avoid dealing with other encodings.
OBS doesn't set C runtime locale so printf function family cannot properly use format specifiers like %ls and %S (capital S) to insert wide strings into narrow strings and vice versa. Instead pre-encode inserted strings to narrow/wide using utf-8 as the target/source encoding and use %s.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Based on changes in #13749 (included in this pr) and further supports #13097
EDIT: The last 2 commits + the merge commit are new.
Change all remaining instances of Windows Ansi api usage to Wide variants.
Pre-encode format specifiers
%lsand%S(capital S) of printf family usingWideCharToMultiByte/MultiByteToWideCharand then%s(small s) instead%lsand%Sspecifiers and thus will fail on anything non-ascii.Motivation and Context
Based on discussions on #13097 to move away from A apis, so OBS doesn't need to deal with the ansi encodings.
How Has This Been Tested?
Tried opening and restarting with a scene with all source types active.
Could still check outputs to console.
Types of changes
Checklist: