- Fix move for readonly folder and file. for now it is a small hack for readonly folders, Small Cleanup in the code, thx w3seek for the help with SetFileAttribs code. Modified: trunk/reactos/lib/kernel32/file/move.c _____
Modified: trunk/reactos/lib/kernel32/file/move.c --- trunk/reactos/lib/kernel32/file/move.c 2005-09-27 21:44:24 UTC (rev 18129) +++ trunk/reactos/lib/kernel32/file/move.c 2005-09-27 21:49:18 UTC (rev 18130) @@ -21,6 +21,19 @@
/* GLOBALS *****************************************************************/
/* FUNCTIONS ****************************************************************/ +static BOOL +RemoveReadOnlyAttributeW(IN LPCWSTR lpFileName) +{ + DWORD Attributes; + Attributes = GetFileAttributesW(lpFileName); + if (Attributes != INVALID_FILE_ATTRIBUTES) + { + return SetFileAttributesW(lpFileName,Attributes - + (Attributes & ~FILE_ATTRIBUTE_READONLY)); + } + + return FALSE; +}
static BOOL AdjustFileAttributes ( @@ -478,26 +491,15 @@ { FindClose(hFile);
- /* delete folder */ + /* delete folder */ + DPRINT("MoveFileWithProgressW : folder : %s\n",lpDeleteFile);
- size = GetFullPathNameW(lpExistingFileName2, MAX_PATH,(LPWSTR) lpDeleteFile, NULL); - if (size>MAX_PATH) - { - lpDeleteFile = (LPCWSTR) HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - (VOID *) lpDeleteFile,size);
- if (lpDeleteFile == NULL) - { - Result = FALSE; - goto FreeMemAndExit; - } + Result = RemoveReadOnlyAttributeW(lpExistingFileName2); + if (Result == FALSE) + break;
- GetFullPathNameW(lpExistingFileName2, size,(LPWSTR) lpDeleteFile, NULL); - } - - DPRINT("MoveFileWithProgressW : folder : %s\n",lpDeleteFile); - - Result = RemoveDirectoryW(lpDeleteFile); + Result = RemoveDirectoryW(lpExistingFileName2); if (Result == FALSE) break; @@ -547,7 +549,18 @@ } }
- wcscpy( (WCHAR *)&lpExistingFileName2[size2-3],findBuffer.cFileName); + wcscpy( (WCHAR *)&lpExistingFileName2[size2-3],findBuffer.cFileName); + + + /* FIXME + * RemoveReadOnlyAttributeW(lpExistingFileName2); is a hack + * for to move readonly folders + */ + wcscpy( (WCHAR *)&lpExistingFileName2[size2+size-3],L"\0"); + RemoveReadOnlyAttributeW(lpExistingFileName2); + + + /* Continue */ wcscpy( (WCHAR *)&lpExistingFileName2[size2+size-3],L"\*.*\0");
@@ -651,6 +664,10 @@ DPRINT("MoveFileWithProgressW : Delete file : %S : %S\n",lpDeleteFile, lpNewFileName2);
+ Result = RemoveReadOnlyAttributeW(lpDeleteFile); + if (Result == FALSE) + break; + Result = DeleteFileW(lpDeleteFile); if (Result == FALSE) {