Bug 925599 - Replace GetVersion() uses. r=bsmedberg
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 22 Nov 2013 12:35:42 +0900
changeset 156991 01e15a1abbb1442f5db4f33203d8cca0bae4c554
parent 156990 a148cd4445aad2f0d650d55dedc8ce7579098c5c
child 156992 2ac1c77672f5f00c2aa45fb88ba090584340e663
push id25694
push usercbook@mozilla.com
push dateFri, 22 Nov 2013 13:45:11 +0000
treeherdermozilla-central@9a179f9b33ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs925599
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 925599 - Replace GetVersion() uses. r=bsmedberg
xpcom/io/SpecialSystemDirectory.cpp
xpcom/io/nsLocalFileWin.cpp
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -14,16 +14,19 @@
 #include <shlobj.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <direct.h>
 #include <shlobj.h>
 #include <knownfolders.h>
 #include <guiddef.h>
+#include "mozilla/WindowsVersion.h"
+
+using mozilla::IsWin7OrLater;
 
 #elif defined(XP_OS2)
 
 #define MAX_PATH _MAX_PATH
 #define INCL_WINWORKPLACE
 #define INCL_DOSMISC
 #define INCL_DOSMODULEMGR
 #define INCL_DOSPROCESS
@@ -150,20 +153,17 @@ SHLoadLibraryFromKnownFolder(REFKNOWNFOL
  * save-to location for the Windows Library passed in through aFolderId.
  * Otherwise falls back on pre-win7 GetWindowsFolder.
  */
 static nsresult
 GetLibrarySaveToPath(int aFallbackFolderId, REFKNOWNFOLDERID aFolderId,
                      nsIFile** aFile)
 {
     // Skip off checking for library support if the os is Vista or lower.
-    DWORD dwVersion = GetVersion();
-    if ((DWORD)(LOBYTE(LOWORD(dwVersion))) < 6 ||
-        ((DWORD)(LOBYTE(LOWORD(dwVersion))) == 6 &&
-         (DWORD)(HIBYTE(LOWORD(dwVersion))) == 0))
+    if (!IsWin7OrLater())
       return GetWindowsFolder(aFallbackFolderId, aFile);
 
     nsRefPtr<IShellLibrary> shellLib;
     nsRefPtr<IShellItem> savePath;
     HRESULT hr =
         SHLoadLibraryFromKnownFolder(aFolderId, STGM_READ,
                                      IID_IShellLibrary, getter_AddRefs(shellLib));
 
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Util.h"
+#include "mozilla/WindowsVersion.h"
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 
 #include "nsLocalFile.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsNativeCharsetUtils.h"
@@ -1829,20 +1830,18 @@ nsLocalFile::CopySingleFile(nsIFile *sou
     // to a SMBV2 remote drive. Without this parameter subsequent append mode
     // file writes can cause the resultant file to become corrupt. We only need to do 
     // this if the major version of Windows is > 5(Only Windows Vista and above 
     // can support SMBV2).  With a 7200RPM hard drive:
     // Copying a 1KB file with COPY_FILE_NO_BUFFERING takes about 30-60ms.
     // Copying a 1KB file without COPY_FILE_NO_BUFFERING takes < 1ms.
     // So we only use COPY_FILE_NO_BUFFERING when we have a remote drive.
     int copyOK;
-    DWORD dwVersion = GetVersion();
-    DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
     DWORD dwCopyFlags = COPY_FILE_ALLOW_DECRYPTED_DESTINATION;
-    if (dwMajorVersion > 5) {
+    if (IsVistaOrLater()) {
         bool path1Remote, path2Remote;
         if (!IsRemoteFilePath(filePath.get(), path1Remote) || 
             !IsRemoteFilePath(destPath.get(), path2Remote) ||
             path1Remote || path2Remote) {
             dwCopyFlags |= COPY_FILE_NO_BUFFERING;
         }
     }