简体   繁体   中英

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM