Skip to content

Add various path utility functions#26

Open
JDeeth wants to merge 3 commits intomkreu:masterfrom
JDeeth:add-paths
Open

Add various path utility functions#26
JDeeth wants to merge 3 commits intomkreu:masterfrom
JDeeth:add-paths

Conversation

@JDeeth
Copy link
Contributor

@JDeeth JDeeth commented Apr 29, 2025

This provides four new functions:

system_path()
prefs_path()
plugin_path()
aircraft_path()

They return PathBuf objects, which the user will presumably find straightforward to navigate from to get, e.g., the aircraft root folder.

I've moved the path_init function to the internal module and promoted paths to pub mod - is that OK?

JDeeth added 3 commits April 29, 2025 20:44
`path_init` is solely used by / useful for the `xplm_init` function so I
don't expect this will cause any difficulties
As std::path::PathBuf rather than string

Only tested on Windows - hopefully works seamlessly with other platforms
due to `XPLM_USE_NATIVE_PATHS` feature?

I've appropriated the `paths` module for them

Fixes mkreu#25
@JDeeth
Copy link
Contributor Author

JDeeth commented Apr 29, 2025

I should mention, I've tested this on Windows only, but would hope it works seamlessly on other platforms!

Fixes #25

Copy link
Owner

@mkreu mkreu left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Looks good to me, just have to minor comments

I will test it on linux and I guess we just hope it works on mac as well :D

}

/// Enables native paths
pub fn path_init() {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pub fn path_init() {
fn path_init() {

Unless I am missing something, there should be no reason anymore for this to be public

Comment on lines +35 to +36
/// X-Plane and plugin paths
pub mod paths;
Copy link
Owner

Choose a reason for hiding this comment

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

We should add docs to the path module that we always return native paths because we turn on the resprective feature during xplm_init.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I missed this... these functions return PathBuf objects from the Rust standard library - isn't that platform-agnostic? I thought the "native paths" feature was a convenience for C programmers!

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