From 67151980b26f961ec42ee9fcff788804af3031c9 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 26 Nov 2007 15:20:58 -0800 Subject: [PATCH] shell32: symlink user's profile shell folders to xdg well known directories --- dlls/shell32/shellpath.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 5be77d7..5d3328f 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -46,6 +46,7 @@ #include "undocshell.h" #include "pidl.h" #include "wine/unicode.h" #include "shlwapi.h" +#include "xdg-user-dir-lookup.h" WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -2004,8 +2005,9 @@ static inline BOOL _SHAppendToUnixPath(c * point directly to $HOME. We assume the user to be a unix hacker who does not * want wine to create anything anywhere besides the .wine directory. So, if * there already is a 'My Music' directory in $HOME, we symlink the 'My Music' - * shell folder to it. But if not, we symlink it to $HOME directly. The same - * holds fo 'My Pictures' and 'My Video'. + * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known" + * directory, and try to link to that. If that fails, then we symlink to + * $HOME directly. The same holds fo 'My Pictures' and 'My Video'. * - The Desktop shell folder is symlinked to '$HOME/Desktop', if that does * exists and left alone if not. * ('My Music',... above in fact means LoadString(IDS_MYMUSIC)) @@ -2014,6 +2016,7 @@ static void _SHCreateSymbolicLinks(void) { UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEO, IDS_MYMUSIC }, i; int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC }; + static const char * lpszXdgDirs[] = { "PICTURES", "VIDEOS", "MUSIC" }; WCHAR wszTempPath[MAX_PATH]; char szPersonalTarget[FILENAME_MAX], *pszPersonal; char szMyStuffTarget[FILENAME_MAX], *pszMyStuff; @@ -2084,9 +2087,22 @@ static void _SHCreateSymbolicLinks(void) } else { - /* Else link to where 'My Documents' itself links to. */ + char * pszXdgDir; + rmdir(pszMyStuff); - symlink(szPersonalTarget, pszMyStuff); + + pszXdgDir = xdg_user_dir_lookup(lpszXdgDirs[i]); + if (pszXdgDir && !stat(pszXdgDir, &statFolder) && S_ISDIR(statFolder.st_mode)) + { + /* the folder specified by XDG_XXX_DIR exists, link to it. */ + symlink(pszXdgDir, pszMyStuff); + } + else + { + /* Else link to where 'My Documents' itself links to. */ + symlink(szPersonalTarget, pszMyStuff); + } + HeapFree(GetProcessHeap(), 0, pszXdgDir); } HeapFree(GetProcessHeap(), 0, pszMyStuff); } -- 1.4.1