Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefix_lowercased and prefix_capitalized? #2

Open
hch12907 opened this issue Dec 7, 2017 · 2 comments
Open

prefix_lowercased and prefix_capitalized? #2

hch12907 opened this issue Dec 7, 2017 · 2 comments

Comments

@hch12907
Copy link

hch12907 commented Dec 7, 2017

  • What are the differences between them?
  • Why does the library require two of them, instead of just calling .to_lowercased() ?
  • Looking at the code, I found that:-
    • The *nix code and Windows code uses lowercased prefix, while OSX uses capitalized. According to my knowledge, Windows is not case-sensitive for the paths, and Linux is. Wouldn't it would make more sense for Linux to use the capitalized prefix, and Windows the lowercased?

(sorry for my english, I am not a native speaker)

@hch12907 hch12907 changed the title Questions on prefix_lowercased and prefix_capitalized. prefix_lowercased and prefix_capitalized? Dec 7, 2017
@tbu-
Copy link
Owner

tbu- commented Dec 7, 2017

I looked at the different platforms and checked what they usually did for their application data. On Linux, most of the directories in ~/.config/ are lowercase, on Windows, most of the directories in AppData\Roaming start with a capital letter.

Windows is only case-insensitive when opening a directory, not when creating it. During the creation, the actual capitalization of the directory name matters, it will be shown that way in the Windows Explorer.

I didn't want to call .to_lowercased because I didn't want to properly handle Unicode. Since you're only calling it once per program, I figured that passing two strings isn't too much of a burden. I'd like additional opinions on this point if you have one. :)

@hch12907
Copy link
Author

hch12907 commented Dec 7, 2017

Oops, I didn't notice that Windows is case-sensitive during directory creation. (derp)

I see your point there.
I think it would be better to have some better docs on this matter. (I had seen the docs, but the difference between Prefix and prefix is small enough to let me take that as some sort of typo, up until I read the code)

One thing to mention though, some of the directories in my ~/.config are capitalized(the first to cross my mind is Slack), and in my %APPDATA% these are kinda mixed. I think most people (take this with a grain of salt) wouldn't mind to have directories with capitalized names.

In my opinion, how about let the users to do something like this, it is much more customizable in comparison to the old code. (For example, users of this lib can let Windows have lowercased prefixes, while giving Macs capitalized prefixes, tho I don't see the point in doing this >.> )

#[cfg(unix)]
let dirs = Directories::with_prefix("foobar");
#[cfg(windows)]
let dirs = Directories::with_prefix("Foobar");

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

No branches or pull requests

2 participants