pipipi
pipipi

Reputation: 551

How to get full path of Documents in C/C++ on Linux (Ubuntu)

As far as I know, "Documents" and all other directories under home are localization related, my question is: is it possible to get full path of "Documents" in C/C++ on Linux (Ubuntu)? Didn't find it in PATH nor other env.

I'm not looking for $HOME, I'm looking for ${HOME}"Documents". For instance, it's "Documents" for English locale, but "文档" for Chinese, etc.

Thanks.

Upvotes: 1

Views: 904

Answers (1)

Mike Dinescu
Mike Dinescu

Reputation: 55760

It looks like, if this is based on the XDG FreeDesktop standard, then there are two files that contain the info:

~/.config/user-dirs.locale

and

~/.config/user-dirs.dirs 

The former contains the locale itself, while the second contains the mapping to the actual folder paths.

References:

[1] https://blogs.gnome.org/simos/2007/11/11/localisation-issues-in-home-directory-folders-xdg-user-dirs/
[2] https://www.freedesktop.org/wiki/Software/xdg-user-dirs/

Upvotes: 3

Related Questions