vkd3d: Add a win32 version of vkd3d_get_program_name.
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
Activity
+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.
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.
added 1 commit
- f7e438d6 - vkd3d: Add a win32 version of vkd3d_get_program_name.
added 43 commits
-
f7e438d6...62a512c4 - 42 commits from branch
wine:master
- 4aef7191 - vkd3d: Add a win32 version of vkd3d_get_program_name.
-
f7e438d6...62a512c4 - 42 commits from branch
added 31 commits
-
4aef7191...962096f1 - 30 commits from branch
wine:master
- d6b1e62f - vkd3d: Add a win32 version of vkd3d_get_program_name.
-
4aef7191...962096f1 - 30 commits from branch