Bug 1316120 - use more Win32 API-ish types in nsLocalFileWin.cpp; r?aklotz
This change works around issues with clang-cl being unable to drop the
__unaligned modifier (which only has an effect on Itanium, which we
don't support) when using static_cast. Instead of static_cast'ing
our way to victory, we instead go through the approved Win32 APIs
to do the translation between all the different types.
MozReview-Commit-ID: 8Z9uL7xY9VN
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -175,55 +175,54 @@ private:
DWORD attributes = GetFileAttributesW(mResolvedPath.get());
if (INVALID_FILE_ATTRIBUTES == attributes) {
return NS_ERROR_FILE_INVALID_PATH;
}
HRESULT hr;
if (attributes & FILE_ATTRIBUTE_DIRECTORY) {
// We have a directory so we should open the directory itself.
- ITEMIDLIST* dir =
- static_cast<ITEMIDLIST*>(ILCreateFromPathW(mResolvedPath.get()));
+ PIDLIST_ABSOLUTE dir = ILCreateFromPathW(mResolvedPath.get());
if (!dir) {
return NS_ERROR_FAILURE;
}
- const ITEMIDLIST* selection[] = { dir };
+ PUITEMID_CHILD child = ILFindLastID(dir);
+ PCUITEMID_CHILD selection[] = { child };
UINT count = ArrayLength(selection);
//Perform the open of the directory.
- hr = SHOpenFolderAndSelectItems(dir, count, selection, 0);
+ hr = SHOpenFolderAndSelectItems(dir, count, &selection[0], 0);
CoTaskMemFree(dir);
} else {
int32_t len = mResolvedPath.Length();
// We don't currently handle UNC long paths of the form \\?\ anywhere so
// this should be fine.
if (len > MAX_PATH) {
return NS_ERROR_FILE_INVALID_PATH;
}
WCHAR parentDirectoryPath[MAX_PATH + 1] = { 0 };
wcsncpy(parentDirectoryPath, mResolvedPath.get(), MAX_PATH);
PathRemoveFileSpecW(parentDirectoryPath);
// We have a file so we should open the parent directory.
- ITEMIDLIST* dir =
- static_cast<ITEMIDLIST*>(ILCreateFromPathW(parentDirectoryPath));
+ PIDLIST_ABSOLUTE dir = ILCreateFromPathW(parentDirectoryPath);
if (!dir) {
return NS_ERROR_FAILURE;
}
// Set the item in the directory to select to the file we want to reveal.
- ITEMIDLIST* item =
- static_cast<ITEMIDLIST*>(ILCreateFromPathW(mResolvedPath.get()));
+ PIDLIST_ABSOLUTE item = ILCreateFromPathW(mResolvedPath.get());
if (!item) {
CoTaskMemFree(dir);
return NS_ERROR_FAILURE;
}
- const ITEMIDLIST* selection[] = { item };
+ PUITEMID_CHILD child = ILFindLastID(dir);
+ PCUITEMID_CHILD selection[] = { child };
UINT count = ArrayLength(selection);
//Perform the selection of the file.
hr = SHOpenFolderAndSelectItems(dir, count, selection, 0);
CoTaskMemFree(dir);
CoTaskMemFree(item);
}