Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find default download directory in linux through c program?

As I titled,

is there any API available, to determine the default download directory in the Linux?

I am using ubuntu distribution.

like image 537
Whoami Avatar asked Oct 31 '12 15:10

Whoami


2 Answers

Quite late to the party but: There is XDG specification that covers exactly this topic. To get the download directory in shell (script) just run:

$ xdg-user-dir DOWNLOAD
/home/djasa/Downloads

For programs, the location is available in $HOME/.config/user-dirs.dirs:

$ grep DOWNLOAD .config/user-dirs.dirs 
XDG_DOWNLOAD_DIR="$HOME/Downloads"

For more information about XDG, read man pages that man -k xdg returns to you.

like image 117
djasa Avatar answered Oct 18 '22 16:10

djasa


There is no "default download directory" at the level of the OS, though all current distros will create a ~/Downloads directory for this purpose and most browsers will choose it by default. What are you trying to accomplish?

like image 34
Andy Ross Avatar answered Oct 18 '22 15:10

Andy Ross