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

Windows support for Base Directories spec #40

Closed ErichDonGubler closed 2 years ago

ErichDonGubler commented 2 years ago

Hey there! Not sure how interesting this is for this repo, but this is some experimental support I've been working on while (1) learning about the Windows permissions model and (2) making Capisco, a side project of mine. I think that this should actually work fairly well, notwithstanding some testing.

See commit messages for details on implementation design; I've tried to create a "nice" abstraction for file permissions as part of this PR. :)

Merge checklist:

whitequark commented 2 years ago

The XDG specifications are only applicable on *nix systems.

ErichDonGubler commented 2 years ago

@whitequark: You're correct that the entire corpus of XDG specs are targeted towards *nix platforms, and I definitely don't think that all (most?) of them would make sense for Windows. That said, the XDG Base Directories specification is actually very portable[^1], and has been used for years now in ecosystems that offer POSIX-like environments in Windows, like the MSYS2 ecosystem (which powers Git for Windows).

I didn't take any time to design a longer-term solution for feature and/or platform selection (since I wasn't sure what other specs you may have ambitions for implementing), but I'd be happy to offer one and/or work with you to find one, assuming you're interested in upstreaming this. :)

[^1]: With some interpretation of how 0700 translates to Windows ACLs, that is. I've taken what is IMO the strictest practical interpretation in this PR.

whitequark commented 2 years ago

That's true. To be more precise, I consider only *nix platforms to be in scope for the xdg crate.

ErichDonGubler commented 2 years ago

@whitequark: Alternatives to this PR for my purposes might be to cfg(unix) the XDG_RUNTIME_DIR portions of this crate, or making them an opt-out feature in Cargo. I don't currently use it, and it'd be a much smaller PR. I imagine somebody might find what I wrote useful for Windows support eventually, but I understand if you don't want to maintain a bunch of Windows-specific logic. Would you be open to such a PR?

whitequark commented 2 years ago

I think there's a few more issues, like the XDG_CONFIG_DIRS variable that's defaulted to /etc/xdg.

ErichDonGubler commented 2 years ago

I'll close this PR, since it seems obvious to me that this implementation direction is infeasible according to your crate design goals.

I think there's a few more issues, like the XDG_CONFIG_DIRS variable that's defaulted to /etc/xdg.

Yes, global paths would need to be audited/conditionally used too, to be consistent with my suggestion. That's a good point.