From 3f2f5685b274bfa8e16999a4bbe5a08274bd9f3c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Dec 2010 12:02:48 -0800 Subject: [PATCH] Platform helpers to detect 64-bit and 32-bit CPU. --- lib/vagrant/util/platform.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 80a825096..4c7a84f16 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -28,6 +28,22 @@ module Vagrant false end + # Returns boolean noting whether this is a 64-bit CPU. This + # is not 100% accurate and there could easily be false negatives. + # + # @return [Boolean] + def bit64? + ["x86_64", "amd64"].include?(::Config::CONFIG["host_cpu"]) + end + + # Returns boolean noting whether this is a 32-bit CPU. This + # can easily throw false positives since it relies on {#bit64?}. + # + # @return [Boolean] + def bit32? + !bit64? + end + def tar_file_options # create, write only, fail if the file exists, binary if windows File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)