From 83d8ef34bbb3283f7bf706fc422895a80e6f93fd Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 7 May 2004 11:18:53 +0000 Subject: [PATCH] Enable the creation of nested desktop and start menu groups. svn path=/trunk/; revision=9318 --- reactos/lib/userenv/desktop.c | 30 +++++++------- reactos/lib/userenv/directory.c | 69 ++++++++++++++++++++++++++++++++- reactos/lib/userenv/internal.h | 9 ++++- 3 files changed, 91 insertions(+), 17 deletions(-) diff --git a/reactos/lib/userenv/desktop.c b/reactos/lib/userenv/desktop.c index 04fd343216a..6163db7411e 100644 --- a/reactos/lib/userenv/desktop.c +++ b/reactos/lib/userenv/desktop.c @@ -1,4 +1,4 @@ -/* $Id: desktop.c,v 1.5 2004/05/05 15:29:15 ekohl Exp $ +/* $Id: desktop.c,v 1.6 2004/05/07 11:18:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -178,15 +178,15 @@ AddDesktopItemW (BOOL bCommonDesktop, &FindData); if (hFind == INVALID_HANDLE_VALUE) { - DPRINT1 ("'%S' does not exist\n", szLinkPath); + DPRINT ("'%S' does not exist\n", szLinkPath); - /* FIXME: create directory path */ - if (!CreateDirectoryW (szLinkPath, NULL)) + /* Create directory path */ + if (!CreateDirectoryPath (szLinkPath, NULL)) return FALSE; } else { - DPRINT1 ("'%S' exists\n", szLinkPath); + DPRINT ("'%S' exists\n", szLinkPath); FindClose (hFind); } @@ -330,7 +330,7 @@ CreateGroupW (LPCWSTR lpGroupName, { WCHAR szGroupPath[MAX_PATH]; - DPRINT ("CreateGroupW() called\n"); + DPRINT1 ("CreateGroupW() called\n"); if (lpGroupName == NULL || *lpGroupName == 0) return TRUE; @@ -340,19 +340,19 @@ CreateGroupW (LPCWSTR lpGroupName, DPRINT1 ("GetProgramsPath() failed\n"); return FALSE; } - DPRINT ("Programs path: '%S'\n", szGroupPath); + DPRINT1 ("Programs path: '%S'\n", szGroupPath); wcscat (szGroupPath, L"\\"); wcscat (szGroupPath, lpGroupName); - DPRINT ("Group path: '%S'\n", szGroupPath); + DPRINT1 ("Group path: '%S'\n", szGroupPath); - /* FIXME: Create directory path */ - if (!CreateDirectoryW (szGroupPath, NULL)) + /* Create directory path */ + if (!CreateDirectoryPath (szGroupPath, NULL)) return FALSE; /* FIXME: Notify the shell */ - DPRINT ("CreateGroupW() done\n"); + DPRINT1 ("CreateGroupW() done\n"); return TRUE; } @@ -389,8 +389,8 @@ DeleteGroupW (LPCWSTR lpGroupName, wcscat (szGroupPath, lpGroupName); DPRINT ("Group path: '%S'\n", szGroupPath); - /* FIXME: Remove directory path */ - if (!RemoveDirectoryW (szGroupPath)) + /* Remove directory path */ + if (!RemoveDirectoryPath (szGroupPath)) return FALSE; /* FIXME: Notify the shell */ @@ -440,7 +440,7 @@ AddItemW (LPCWSTR lpGroupName, HRESULT hr; BOOL bResult; - DPRINT ("AddDesktopItemW() called\n"); + DPRINT ("AddItemW() called\n"); bResult = FALSE; @@ -560,7 +560,7 @@ AddItemW (LPCWSTR lpGroupName, CoUninitialize(); - DPRINT ("AddDesktopItemW() done\n"); + DPRINT ("AddItemW() done\n"); return bResult; } diff --git a/reactos/lib/userenv/directory.c b/reactos/lib/userenv/directory.c index 26d981b7cd0..9bc5e62df9f 100644 --- a/reactos/lib/userenv/directory.c +++ b/reactos/lib/userenv/directory.c @@ -1,4 +1,4 @@ -/* $Id: directory.c,v 1.2 2004/01/16 15:31:53 ekohl Exp $ +/* $Id: directory.c,v 1.3 2004/05/07 11:18:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -116,4 +116,71 @@ CopyDirectory (LPCWSTR lpDestinationPath, return TRUE; } + +BOOL +CreateDirectoryPath (LPCWSTR lpPathName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes) +{ + WCHAR szPath[MAX_PATH]; + LPWSTR Ptr; + DWORD dwError; + + DPRINT ("CreateDirectoryPath() called\n"); + + if (lpPathName == NULL || *lpPathName == 0) + return TRUE; + + if (CreateDirectoryW (lpPathName, + lpSecurityAttributes)) + return TRUE; + + dwError = GetLastError (); + if (dwError == ERROR_ALREADY_EXISTS) + return TRUE; + + wcscpy (szPath, lpPathName); + + if (wcslen(szPath) > 3 && szPath[1] == ':' && szPath[2] == '\\') + { + Ptr = &szPath[3]; + } + else + { + Ptr = szPath; + } + + while (Ptr != NULL) + { + Ptr = wcschr (Ptr, L'\\'); + if (Ptr != NULL) + *Ptr = 0; + + DPRINT ("CreateDirectory(%S)\n", szPath); + if (!CreateDirectoryW (szPath, + lpSecurityAttributes)) + { + dwError = GetLastError (); + if (dwError != ERROR_ALREADY_EXISTS) + return FALSE; + } + + if (Ptr != NULL) + { + *Ptr = L'\\'; + Ptr++; + } + } + + DPRINT ("CreateDirectoryPath() done\n"); + + return TRUE; +} + + +BOOL +RemoveDirectoryPath (LPCWSTR lpPathName) +{ + return RemoveDirectoryW (lpPathName); +} + /* EOF */ diff --git a/reactos/lib/userenv/internal.h b/reactos/lib/userenv/internal.h index 4458b5fb8b6..8343e2d4354 100644 --- a/reactos/lib/userenv/internal.h +++ b/reactos/lib/userenv/internal.h @@ -1,4 +1,4 @@ -/* $Id: internal.h,v 1.5 2004/03/13 20:49:07 ekohl Exp $ +/* $Id: internal.h,v 1.6 2004/05/07 11:18:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -29,6 +29,13 @@ BOOL CopyDirectory (LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath); +BOOL +CreateDirectoryPath (LPCWSTR lpPathName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); + +BOOL +RemoveDirectoryPath (LPCWSTR lpPathName); + /* misc.c */ LPWSTR AppendBackslash (LPWSTR String);