whitequark / rust-xdg

A library that makes it easy to follow the X Desktop Group specifications
https://wiki.freedesktop.org/www/Specifications/
Apache License 2.0
154 stars 30 forks source link

Add support for missing $HOME #64

Closed julianandrews closed 1 year ago

julianandrews commented 1 year ago

Move failures to call time rather than BaseDirectories creation.

This means, for instance, that create_config_directory() can work if XDG_CONFIG_HOME is defined even if HOME isn't.

This also means that methods like find_data_file() and find_config_file() will work without a home directory, which can be useful for software that wants to support both use by regular users and use by system accounts without HOME.

I tried to write a test case, but std::env::home_dir() will figure out the home dir even if HOME is unset, which makes meaningful testing quite difficult.

julianandrews commented 1 year ago

This PR is should resolve #47.

whitequark commented 1 year ago

Do you think you could also handle #44? Given we aren't really checking much in the constructor now.

julianandrews commented 1 year ago

Do you think you could also handle #44? Given we aren't really checking much in the constructor now.

Sure. I'll get a PR together sometime this weekend.

I think this change would let me add the test case I was missing for the this PR!