Author: jgardou
Date: Sat Dec 8 22:11:41 2012
New Revision: 57830
URL:
http://svn.reactos.org/svn/reactos?rev=57830&view=rev
Log:
[USERENV]
- Formatting, no code change
Modified:
trunk/reactos/dll/win32/userenv/directory.c
Modified: trunk/reactos/dll/win32/userenv/directory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/director…
==============================================================================
--- trunk/reactos/dll/win32/userenv/directory.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/userenv/directory.c [iso-8859-1] Sat Dec 8 22:11:41 2012
@@ -35,301 +35,301 @@
BOOL WINAPI
CopyProfileDirectoryA(LPCSTR lpSourcePath,
- LPCSTR lpDestinationPath,
- DWORD dwFlags)
-{
- UNICODE_STRING SrcPath;
- UNICODE_STRING DstPath;
- NTSTATUS Status;
- BOOL bResult;
-
- Status = RtlCreateUnicodeStringFromAsciiz(&SrcPath,
- (LPSTR)lpSourcePath);
- if (!NT_SUCCESS(Status))
- {
- SetLastError (RtlNtStatusToDosError (Status));
- return FALSE;
- }
-
- Status = RtlCreateUnicodeStringFromAsciiz(&DstPath,
- (LPSTR)lpDestinationPath);
- if (!NT_SUCCESS(Status))
- {
- RtlFreeUnicodeString(&SrcPath);
- SetLastError (RtlNtStatusToDosError (Status));
- return FALSE;
- }
-
- bResult = CopyProfileDirectoryW(SrcPath.Buffer,
- DstPath.Buffer,
- dwFlags);
-
- RtlFreeUnicodeString(&DstPath);
- RtlFreeUnicodeString(&SrcPath);
-
- return bResult;
+ LPCSTR lpDestinationPath,
+ DWORD dwFlags)
+{
+ UNICODE_STRING SrcPath;
+ UNICODE_STRING DstPath;
+ NTSTATUS Status;
+ BOOL bResult;
+
+ Status = RtlCreateUnicodeStringFromAsciiz(&SrcPath,
+ (LPSTR)lpSourcePath);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError (RtlNtStatusToDosError (Status));
+ return FALSE;
+ }
+
+ Status = RtlCreateUnicodeStringFromAsciiz(&DstPath,
+ (LPSTR)lpDestinationPath);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlFreeUnicodeString(&SrcPath);
+ SetLastError (RtlNtStatusToDosError (Status));
+ return FALSE;
+ }
+
+ bResult = CopyProfileDirectoryW(SrcPath.Buffer,
+ DstPath.Buffer,
+ dwFlags);
+
+ RtlFreeUnicodeString(&DstPath);
+ RtlFreeUnicodeString(&SrcPath);
+
+ return bResult;
}
BOOL WINAPI
CopyProfileDirectoryW(LPCWSTR lpSourcePath,
- LPCWSTR lpDestinationPath,
- DWORD dwFlags)
-{
- /* FIXME: dwFlags are ignored! */
- return CopyDirectory(lpDestinationPath, lpSourcePath);
+ LPCWSTR lpDestinationPath,
+ DWORD dwFlags)
+{
+ /* FIXME: dwFlags are ignored! */
+ return CopyDirectory(lpDestinationPath, lpSourcePath);
}
BOOL
CopyDirectory (LPCWSTR lpDestinationPath,
- LPCWSTR lpSourcePath)
-{
- WCHAR szFileName[MAX_PATH];
- WCHAR szFullSrcName[MAX_PATH];
- WCHAR szFullDstName[MAX_PATH];
- WIN32_FIND_DATAW FindFileData;
- LPWSTR lpSrcPtr;
- LPWSTR lpDstPtr;
- HANDLE hFind;
-
- DPRINT ("CopyDirectory (%S, %S) called\n",
- lpDestinationPath, lpSourcePath);
-
- wcscpy (szFileName, lpSourcePath);
- wcscat (szFileName, L"\\*.*");
-
- hFind = FindFirstFileW (szFileName,
- &FindFileData);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
- return FALSE;
- }
-
- wcscpy (szFullSrcName, lpSourcePath);
- lpSrcPtr = AppendBackslash (szFullSrcName);
-
- wcscpy (szFullDstName, lpDestinationPath);
- lpDstPtr = AppendBackslash (szFullDstName);
-
- for (;;)
- {
- if (wcscmp (FindFileData.cFileName, L".") &&
- wcscmp (FindFileData.cFileName, L".."))
- {
- wcscpy (lpSrcPtr, FindFileData.cFileName);
- wcscpy (lpDstPtr, FindFileData.cFileName);
-
- if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- DPRINT ("Create directory: %S\n", szFullDstName);
- if (!CreateDirectoryExW (szFullSrcName, szFullDstName, NULL))
- {
- if (GetLastError () != ERROR_ALREADY_EXISTS)
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
-
- FindClose (hFind);
- return FALSE;
- }
- }
-
- if (!CopyDirectory (szFullDstName, szFullSrcName))
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
-
- FindClose (hFind);
- return FALSE;
- }
- }
- else
- {
- DPRINT ("Copy file: %S -> %S\n", szFullSrcName, szFullDstName);
- if (!CopyFileW (szFullSrcName, szFullDstName, FALSE))
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
-
- FindClose (hFind);
- return FALSE;
- }
- }
- }
-
- if (!FindNextFileW (hFind, &FindFileData))
- {
- if (GetLastError () != ERROR_NO_MORE_FILES)
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
- }
-
- break;
- }
- }
-
- FindClose (hFind);
-
- DPRINT ("CopyDirectory() done\n");
-
- return TRUE;
+ LPCWSTR lpSourcePath)
+{
+ WCHAR szFileName[MAX_PATH];
+ WCHAR szFullSrcName[MAX_PATH];
+ WCHAR szFullDstName[MAX_PATH];
+ WIN32_FIND_DATAW FindFileData;
+ LPWSTR lpSrcPtr;
+ LPWSTR lpDstPtr;
+ HANDLE hFind;
+
+ DPRINT ("CopyDirectory (%S, %S) called\n",
+ lpDestinationPath, lpSourcePath);
+
+ wcscpy (szFileName, lpSourcePath);
+ wcscat (szFileName, L"\\*.*");
+
+ hFind = FindFirstFileW (szFileName,
+ &FindFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+ return FALSE;
+ }
+
+ wcscpy (szFullSrcName, lpSourcePath);
+ lpSrcPtr = AppendBackslash (szFullSrcName);
+
+ wcscpy (szFullDstName, lpDestinationPath);
+ lpDstPtr = AppendBackslash (szFullDstName);
+
+ for (;;)
+ {
+ if (wcscmp (FindFileData.cFileName, L".") &&
+ wcscmp (FindFileData.cFileName, L".."))
+ {
+ wcscpy (lpSrcPtr, FindFileData.cFileName);
+ wcscpy (lpDstPtr, FindFileData.cFileName);
+
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ DPRINT ("Create directory: %S\n", szFullDstName);
+ if (!CreateDirectoryExW (szFullSrcName, szFullDstName, NULL))
+ {
+ if (GetLastError () != ERROR_ALREADY_EXISTS)
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+
+ FindClose (hFind);
+ return FALSE;
+ }
+ }
+
+ if (!CopyDirectory (szFullDstName, szFullSrcName))
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+
+ FindClose (hFind);
+ return FALSE;
+ }
+ }
+ else
+ {
+ DPRINT ("Copy file: %S -> %S\n", szFullSrcName,
szFullDstName);
+ if (!CopyFileW (szFullSrcName, szFullDstName, FALSE))
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+
+ FindClose (hFind);
+ return FALSE;
+ }
+ }
+ }
+
+ if (!FindNextFileW (hFind, &FindFileData))
+ {
+ if (GetLastError () != ERROR_NO_MORE_FILES)
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+ }
+
+ break;
+ }
+ }
+
+ FindClose (hFind);
+
+ DPRINT ("CopyDirectory() done\n");
+
+ 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)
+ 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;
-
- 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;
}
static BOOL
RecursiveRemoveDir (LPCWSTR lpPath)
{
- WCHAR szPath[MAX_PATH];
- WIN32_FIND_DATAW FindData;
- HANDLE hFind;
- BOOL bResult;
-
- wcscpy (szPath, lpPath);
- wcscat (szPath, L"\\*.*");
- DPRINT ("Search path: '%S'\n", szPath);
-
- hFind = FindFirstFileW (szPath,
- &FindData);
- if (hFind == INVALID_HANDLE_VALUE)
- return FALSE;
-
- bResult = TRUE;
- while (TRUE)
- {
- if (wcscmp (FindData.cFileName, L".") &&
- wcscmp (FindData.cFileName, L".."))
- {
- wcscpy (szPath, lpPath);
- wcscat (szPath, L"\\");
- wcscat (szPath, FindData.cFileName);
- DPRINT ("File name: '%S'\n", szPath);
-
- if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- DPRINT ("Delete directory: '%S'\n", szPath);
-
- if (!RecursiveRemoveDir (szPath))
- {
- bResult = FALSE;
- break;
- }
-
- if (FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- {
- SetFileAttributesW (szPath,
- FindData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
- }
-
- if (!RemoveDirectoryW (szPath))
- {
- bResult = FALSE;
- break;
- }
- }
- else
- {
- DPRINT ("Delete file: '%S'\n", szPath);
-
- if (FindData.dwFileAttributes & (FILE_ATTRIBUTE_READONLY |
FILE_ATTRIBUTE_SYSTEM))
- {
- SetFileAttributesW (szPath,
- FILE_ATTRIBUTE_NORMAL);
- }
-
- if (!DeleteFileW (szPath))
- {
- bResult = FALSE;
- break;
- }
- }
- }
-
- if (!FindNextFileW (hFind, &FindData))
- {
- if (GetLastError () != ERROR_NO_MORE_FILES)
- {
- DPRINT1 ("Error: %lu\n", GetLastError());
- bResult = FALSE;
- break;
- }
-
- break;
- }
- }
-
- FindClose (hFind);
-
- return bResult;
+ WCHAR szPath[MAX_PATH];
+ WIN32_FIND_DATAW FindData;
+ HANDLE hFind;
+ BOOL bResult;
+
+ wcscpy (szPath, lpPath);
+ wcscat (szPath, L"\\*.*");
+ DPRINT ("Search path: '%S'\n", szPath);
+
+ hFind = FindFirstFileW (szPath,
+ &FindData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ bResult = TRUE;
+ while (TRUE)
+ {
+ if (wcscmp (FindData.cFileName, L".") &&
+ wcscmp (FindData.cFileName, L".."))
+ {
+ wcscpy (szPath, lpPath);
+ wcscat (szPath, L"\\");
+ wcscat (szPath, FindData.cFileName);
+ DPRINT ("File name: '%S'\n", szPath);
+
+ if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ DPRINT ("Delete directory: '%S'\n", szPath);
+
+ if (!RecursiveRemoveDir (szPath))
+ {
+ bResult = FALSE;
+ break;
+ }
+
+ if (FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ {
+ SetFileAttributesW (szPath,
+ FindData.dwFileAttributes &
~FILE_ATTRIBUTE_READONLY);
+ }
+
+ if (!RemoveDirectoryW (szPath))
+ {
+ bResult = FALSE;
+ break;
+ }
+ }
+ else
+ {
+ DPRINT ("Delete file: '%S'\n", szPath);
+
+ if (FindData.dwFileAttributes & (FILE_ATTRIBUTE_READONLY |
FILE_ATTRIBUTE_SYSTEM))
+ {
+ SetFileAttributesW (szPath,
+ FILE_ATTRIBUTE_NORMAL);
+ }
+
+ if (!DeleteFileW (szPath))
+ {
+ bResult = FALSE;
+ break;
+ }
+ }
+ }
+
+ if (!FindNextFileW (hFind, &FindData))
+ {
+ if (GetLastError () != ERROR_NO_MORE_FILES)
+ {
+ DPRINT1 ("Error: %lu\n", GetLastError());
+ bResult = FALSE;
+ break;
+ }
+
+ break;
+ }
+ }
+
+ FindClose (hFind);
+
+ return bResult;
}
BOOL
RemoveDirectoryPath (LPCWSTR lpPathName)
{
- if (!RecursiveRemoveDir (lpPathName))
- return FALSE;
-
- DPRINT ("Delete directory: '%S'\n", lpPathName);
- return RemoveDirectoryW (lpPathName);
+ if (!RecursiveRemoveDir (lpPathName))
+ return FALSE;
+
+ DPRINT ("Delete directory: '%S'\n", lpPathName);
+ return RemoveDirectoryW (lpPathName);
}
/* EOF */