<commit_before>require "rbconfig"
require "shellwords"
require "tmpdir"

require "vagrant/util/subprocess"
require "vagrant/util/powershell"

module Vagrant
  module Util
    # This class just contains some platform checking code.
    class Platform
      class << self
        def cygwin?
          return @_cygwin if defined?(@_cygwin)
          @_cygwin = -> {
            # Installer detects Cygwin
            return true if ENV["VAGRANT_DETECTED_OS"] &&
              ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")

            # Ruby running in Cygwin
            return true if platform.include?("cygwin")

            # Heuristic. If the path contains Cygwin, we just assume we're
            # in Cygwin. It is generally a safe bet.
            path = ENV["PATH"] || ""
            return path.include?("cygwin")
          }.call
          return @_cygwin
        end

        [:darwin, :bsd, :freebsd, :linux, :solaris].each do |type|
          define_method("#{type}?") do
            platform.include?(type.to_s)
          end
        end

        def windows?
          return @_windows if defined?(@_windows)
          @_windows = %w[mingw mswin].any? { |t| platform.include?(t) }
          return @_windows
        end

        # Checks if the user running Vagrant on Windows has administrative
        # privileges.
        #
        # From: https://support.microsoft.com/en-us/kb/243330
        # SID: S-1-5-19
        #
        # @return [Boolean]
        def windows_admin?
          return @_windows_admin if defined?(@_windows_admin)

          @_windows_admin = -> {
            ps_cmd = "[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | ForEach-Object { if ($_.Value -eq 'S-1-5-19'){ Write-Host 'true'; break }}"
            output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
            return output == 'true'
          }.call

          return @_windows_admin
        end

        # Checks if the user running Vagrant on Windows is a member of the
        # "Hyper-V Administrators" group.
        #
        # From: https://support.microsoft.com/en-us/kb/243330
        # SID: S-1-5-32-578
        # Name: BUILTIN\Hyper-V Administrators
        #
        # @return [Boolean]
        def windows_hyperv_admin?
          return @_windows_hyperv_admin if defined?(@_windows_hyperv_admin)

          @_windows_hyperv_admin = -> {
            ps_cmd = "[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | ForEach-Object { if ($_.Value -eq 'S-1-5-32-578'){ Write-Host 'true'; break }}"
            output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
            return output == 'true'
          }.call

          return @_windows_hyperv_admin
        end

        # This takes any path and converts it from a Windows path to a
        # Cygwin or msys style path.
        #<commit_msg>Fixed admin test to verify that you are running in an elevated shell, not that you are in the administrators group since that is not required.<commit_after>require "rbconfig"
require "shellwords"
require "tmpdir"

require "vagrant/util/subprocess"
require "vagrant/util/powershell"

module Vagrant
  module Util
    # This class just contains some platform checking code.
    class Platform
      class << self
        def cygwin?
          return @_cygwin if defined?(@_cygwin)
          @_cygwin = -> {
            # Installer detects Cygwin
            return true if ENV["VAGRANT_DETECTED_OS"] &&
              ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")

            # Ruby running in Cygwin
            return true if platform.include?("cygwin")

            # Heuristic. If the path contains Cygwin, we just assume we're
            # in Cygwin. It is generally a safe bet.
            path = ENV["PATH"] || ""
            return path.include?("cygwin")
          }.call
          return @_cygwin
        end

        [:darwin, :bsd, :freebsd, :linux, :solaris].each do |type|
          define_method("#{type}?") do
            platform.include?(type.to_s)
          end
        end

        def windows?
          return @_windows if defined?(@_windows)
          @_windows = %w[mingw mswin].any? { |t| platform.include?(t) }
          return @_windows
        end

        # Checks if the user running Vagrant on Windows has administrative
        # privileges.
        #
        # From: https://support.microsoft.com/en-us/kb/243330
        # SID: S-1-5-19
        #
        # @return [Boolean]
        def windows_admin?
          return @_windows_admin if defined?(@_windows_admin)

          @_windows_admin = -> {
            ps_cmd = '(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)'
            output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
            return output == 'True'
          }.call

          return @_windows_admin
        end

        # Checks if the user running Vagrant on Windows is a member of the
        # "Hyper-V Administrators" group.
        #
        # From: https://support.microsoft.com/en-us/kb/243330
        # SID: S-1-5-32-578
        # Name: BUILTIN\Hyper-V Administrators
        #
        # @return [Boolean]
        def windows_hyperv_admin?
          return @_windows_hyperv_admin if defined?(@_windows_hyperv_admin)

          @_windows_hyperv_admin = -> {
            ps_cmd = "[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | ForEach-Object { if ($_.Value -eq 'S-1-5-32-578'){ Write-Host 'true'; break }}"
            output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
            return output == 'true'
          }.call

          return @_windows_hyperv_admin
        end

        # This takes any path and converts it from a Windows path to a
        # Cygwin or msys style path.
        #
{'fraction_non_alphanumeric': 0.10588035350101971, 'fraction_numerical': 0.010876954452753228, 'mean_word_length': 2.0444904293843766, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4305091', 'n_tokens_mistral': 1825, 'n_tokens_neox': 1731, 'n_words': 444}