This helper function takes any full file path and extracts only the last two components, such as `"R/add.R"`. It supports both forward slashes (`/`) and backslashes (`\`) to accommodate Windows, macOS, and Linux paths.
Value
A character scalar containing the last two components of the path joined
with a forward slash—for example `"R/add.R"`—or a single component if only
one exists. The returned value is always of class character.
Details
Trailing separators are preserved where meaningful (e.g., `"R/"` when the input ends with a slash). Empty path components are removed except when required to detect a trailing separator.