Skip to content

Conversation

@daljit46
Copy link
Member

This function queries the operating system for the path of the running process and returns it as a std::filesystem::path. Platform-specific behaviour:

  • Windows: uses GetModuleFileNameW.
  • macOS: uses _NSGetExecutablePath.
  • Linux: reads the /proc/self/exe symlink.

An example where this can be useful is #3096, where shader files are copied next to the executable file.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@daljit46 daljit46 force-pushed the exec_path branch 4 times, most recently from b33080b to 6781495 Compare October 13, 2025 16:34
This function queries the operating system for the path of the running
process and returns it as a `std::filesystem::path`. Platform-specific
behaviour:
 - Windows: uses `GetModuleFileNameW`.
 - macOS: uses `_NSGetExecutablePath`.
 - Linux: reads the `/proc/self/exe` symlink.
@daljit46 daljit46 requested a review from a team October 13, 2025 16:42
@Lestropie
Copy link
Member

There's existing envvars MRTRIX_WINDOWS and MRTRIX_MACOSX; I don't have any particular argument for persisting with those vs. using generic ones, but might be preferable to stick with one convention or the other. Also MRTRIX_FREEBSD, no idea if that distinction is consequential here.

Copy link
Member

@Lestropie Lestropie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on MSYS2, Linux, WSL2. Notably MSYS2 gives a Windows native path, and printing gives double-slashes as path separators, but I'm guessing this is a behaviour of std::filesystem_path?

@daljit46 daljit46 merged commit 388f46f into dev Oct 29, 2025
6 checks passed
@daljit46 daljit46 deleted the exec_path branch October 29, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants