From: Serge Gautherie Date: Mon, 9 Jan 2017 11:10:40 +0100 Subject: [SHELL32] reactos\dll\win32\kernel32\client\file\disk.c: *4 code "style" fixes. reactos\dll\win32\shell32\folders\CRecycleBin.cpp: *TRASH_CanTrashFile(): Create and use 'wszRootPathName'. CORE-12340 diff --git a/reactos/dll/win32/kernel32/client/file/disk.c b/reactos/dll/win32/kernel32/client/file/disk.c index 4f29f47..c8c81b5 100644 --- a/reactos/dll/win32/kernel32/client/file/disk.c +++ b/reactos/dll/win32/kernel32/client/file/disk.c @@ -183,7 +183,7 @@ GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, { GetCurrentDirectoryW (MAX_PATH, RootPathName); } - RootPathName[3] = 0; + RootPathName[3] = L'\0'; hFile = InternalOpenDirW(RootPathName, FALSE); if (INVALID_HANDLE_VALUE == hFile) @@ -401,7 +401,7 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName) } if (wcslen(CurrentDir) > 3) - CurrentDir[3] = 0; + CurrentDir[3] = L'\0'; lpRootPath = CurrentDir; } @@ -449,7 +449,7 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName) if (CurrentDir != NULL) HeapFree(GetProcessHeap(), 0, CurrentDir); - if (PathName.Buffer[(PathName.Length >> 1) - 1] != L'\\') + if (PathName.Buffer[(PathName.Length / sizeof(WCHAR)) - 1] != L'\\') { return DRIVE_NO_ROOT_DIR; } @@ -479,7 +479,7 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName) NtClose(FileHandle); if (!NT_SUCCESS(Status)) { - return 0; + return DRIVE_UNKNOWN; } switch (FileFsDevice.DeviceType) diff --git a/reactos/dll/win32/shell32/folders/CRecycleBin.cpp b/reactos/dll/win32/shell32/folders/CRecycleBin.cpp index ba80e3b..dd159f8 100644 --- a/reactos/dll/win32/shell32/folders/CRecycleBin.cpp +++ b/reactos/dll/win32/shell32/folders/CRecycleBin.cpp @@ -903,18 +903,28 @@ TRASH_CanTrashFile(LPCWSTR wszPath) return FALSE; } - if (GetDriveTypeW(wszPath) != DRIVE_FIXED) + { // wszRootPathName + + // Only keep the base path. + WCHAR wszRootPathName[MAX_PATH]; + strcpyW(wszRootPathName, wszPath); + PathRemoveFileSpecW(wszRootPathName); + PathAddBackslashW(wszRootPathName); + + if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED) { /* no bitbucket on removable media */ return FALSE; } - if (!GetVolumeInformationW(wszPath, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0)) + if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0)) { ERR("GetVolumeInformationW failed with %u\n", GetLastError()); return FALSE; } + } // wszRootPathName + swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber)); wcscat(szKey, szBuffer);