Skip to content

Update nf-pathcch-pathcchaddbackslash.md #1185

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

Open
wants to merge 1 commit into
base: docs
Choose a base branch
from

Conversation

oold
Copy link
Contributor

@oold oold commented Jun 7, 2022

Refer to the PathCchAddBackslashEx function when mentioning the MAX_PATH limitation.

Refer to the PathCchAddBackslashEx function when mentioning the MAX_PATH limitation.
@PRMerger6 PRMerger6 requested a review from jwmsft June 7, 2022 12:17
@PRMerger6
Copy link

@oold : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@oold
Copy link
Contributor Author

oold commented Jun 7, 2022

@jwmsft Actually, after checking in Compiler Explorer, it seems that the PathCchAddBackslash function doesn't have the MAX_PATH limitation at all.

Program:

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>

#include <PathCch.h>
#pragma comment(lib, "pathcch")

#include <cstdlib>
#include <cwchar>
#include <iostream>

int main() {
    wchar_t szMyPath[PATHCCH_MAX_CCH] = L"C:";
    for (SIZE_T i = 0; i < 10; ++i)
        std::wcscat(szMyPath, L"\\qwertyuiopasdfghjklzxcvbnm");
    if (FAILED(PathCchAddBackslash(szMyPath, PATHCCH_MAX_CCH)))
        return EXIT_FAILURE;
    std::wcout << L"Len: " << std::wcslen(szMyPath) << L'\n' << szMyPath << L'\n';
}

Output:

Len: 273
C:\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\qwertyuiopasdfghjklzxcvbnm\

The entire paragraph could be deleted if that behavior is intended.

@asklar
Copy link
Contributor

asklar commented Jun 10, 2022

it's possible that the behavior might differ on different Windows versions

@oold
Copy link
Contributor Author

oold commented Jul 2, 2022

Considering that the page previously mentioned MAX_PATH, I guess it would be okay to keep the pull request the way it is. Someone else can fix that if it's truly wrong. It's not like I can look at the code of this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants