LCOV - code coverage report
Current view: top level - server/ioutil - HostPlatform.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 8 8 100.0 %
Date: 2022-11-19 15:00:39 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2009 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.ioutil;
      16             : 
      17             : import java.security.AccessController;
      18             : import java.security.PrivilegedAction;
      19             : 
      20             : public final class HostPlatform {
      21         139 :   private static final boolean win32 = compute("windows");
      22         139 :   private static final boolean mac = compute("mac");
      23             : 
      24             :   /** Returns true if this JVM is running on a Windows platform. */
      25             :   public static boolean isWin32() {
      26         139 :     return win32;
      27             :   }
      28             : 
      29             :   public static boolean isMac() {
      30           1 :     return mac;
      31             :   }
      32             : 
      33             :   private static boolean compute(String platform) {
      34         139 :     final String osDotName =
      35         139 :         AccessController.doPrivileged(
      36         139 :             (PrivilegedAction<String>) () -> System.getProperty("os.name"));
      37         139 :     return osDotName != null && osDotName.toLowerCase().contains(platform);
      38             :   }
      39             : 
      40             :   private HostPlatform() {}
      41             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750