Skip to content
Snippets Groups Projects

vkd3d: Add a win32 version of vkd3d_get_program_name.

Merged Stefan Dösinger requested to merge stefan/vkd3d:progname into master

Taken from wined3d_get_app_name with some adjustments.

I'll use this for the default cache filename, but I think it makes sense on its own because we pass this information to Vulkan. Wine's d3d12 passes a struct vkd3d_application_info, but doesn't set the application name.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Giovanni Mascellani approved this merge request

    approved this merge request

  • +bool vkd3d_get_program_name(char program_name[PATH_MAX])
    +{
    +    char buffer[MAX_PATH];
    +    unsigned int len;
    +    char *p, *name;
    +
    +    *program_name = '\0';
    +    len = GetModuleFileNameA(0, buffer, ARRAY_SIZE(buffer));

    "NULL" is probably more appropriate than 0 here.

    +    if (!(len && len < MAX_PATH))
    +        return false;
    +
    +    name = buffer;
    +    if ((p = strrchr(name, '/' )))

    Stray space above.

    +        name = p + 1;
    +    if ((p = strrchr(name, '\\')))
    +        name = p + 1;
    +
    +    strcpy(program_name, name);
    +    return true;
    +}

    I think I like the memcpy() in the original better. You probably don't need the strlen() it has, although I suppose it's convenient. You could conceivably also avoid the temporary buffer, and use memmove().

  • added 1 commit

    • bc4f4f5a - vkd3d: Add a win32 version of vkd3d_get_program_name.

    Compare with previous version

  • Author Contributor

    I think I like the memcpy() in the original better. You probably don't need the strlen() it has, although I suppose it's convenient. You could conceivably also avoid the temporary buffer, and use memmove().

    I changed the other two things, but I prefer the strcpy. That's not a strong preference, so I'll change it to strlen + memcpy if you insist.

    Re writing to program_name directly, then memmove'ing, I think this makes the code more difficult to read. This function is not called in a performance critical path and the 260 chars of MAX_PATH are a rounding error nowadays, so I don't see any upside of saving the extra array.

  • Author Contributor

    After talking with Henri I changed it to strlen + memcpy; I could replace the "strlen(name) + 1" with something like "len -= name - buffer - 1;" but I am not a fan of it.

  • added 1 commit

    • f7e438d6 - vkd3d: Add a win32 version of vkd3d_get_program_name.

    Compare with previous version

  • This has a (possibly unrelated) CI failure, but seems fine otherwise.

  • added 43 commits

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • added 31 commits

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

Please register or sign in to reply
Loading