xdg-rs / dirs

a low-level library that provides config/cache/data paths, following the respective conventions on Linux, macOS and Windows
186 stars 23 forks source link

Support machine global directory #44

Open timfish opened 3 years ago

timfish commented 3 years ago

There's currently no way to get a machine global (ie. non user/home scoped) data directory. This is useful for examples if you want to download large files that can be shared between users.

This would look something like:

This is currently supported by app-dirs via SharedData but the crate is unmaintained.

Would you be open to accepting a PR for this?

tesuji commented 3 years ago

Thank you for opening this issue.

Would you be open to accepting a PR for this?

Yes, you're welcome. But could you talk a bit about the API you planned to add?

I have some thoughts about this:

  1. For dirs_next crate, we could either: a. Add an enum Location { User, Shared, System } (?), use that enum as a parameter of free functions in dirsnext. But this is a breaking change. So we need to bump major version after doing this. b. Add new free functions with `shared` prefix.
  2. For directories crate: a. Introduce a new SharedDirs struct?

Do you know if any other crates expose the same information?

timfish commented 3 years ago

@lzutao as I said above, app-dirs already exposes this as SharedData but the crate seems unmaintained.

tesuji commented 3 years ago

SharedData is a variant of AppDataType enum. AppDataType is used as an argument to configure the behavior of app_dir function and friends.

That would be option 1a I listed above. And that will need a major version bump. So I would like to hear more about what others think about this issue.