From 82eafe525ebc1f3ed00227a97bc27777b3928811 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 16 Nov 2007 14:39:03 -0800 Subject: [PATCH] shell32: symlink user's profile shell folders to xdg well known directories --- dlls/shell32/shellpath.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 5be77d7..595b77b 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -2004,8 +2004,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 +2015,7 @@ static void _SHCreateSymbolicLinks(void) { UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEO, IDS_MYMUSIC }, i; int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC }; + const char * xdg[] = { "XDG_PICTURES_DIR", "XDG_VIDEOS_DIR", "XDG_MUSIC_DIR" }; WCHAR wszTempPath[MAX_PATH]; char szPersonalTarget[FILENAME_MAX], *pszPersonal; char szMyStuffTarget[FILENAME_MAX], *pszMyStuff; @@ -2084,9 +2086,21 @@ static void _SHCreateSymbolicLinks(void) } else { - /* Else link to where 'My Documents' itself links to. */ + char * pszXdgDir; + rmdir(pszMyStuff); - symlink(szPersonalTarget, pszMyStuff); + + pszXdgDir = getenv(xdg[i]); + if (pszXdgDir && !stat(pszXdgDir, &statFolder) && S_ISDIR(statFolder.st_mode)) + { + /* the folder specified by XDG_XXX_DIR exists, link to it. */ + symlink(getenv(xdg[i]), pszMyStuff); + } + else + { + /* Else link to where 'My Documents' itself links to. */ + symlink(szPersonalTarget, pszMyStuff); + } } HeapFree(GetProcessHeap(), 0, pszMyStuff); } -- 1.4.1