Skip to content

Commit

Permalink
Use DiskAnalyzer to check for Windows partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Sep 27, 2016
1 parent 116984e commit a16a5cd
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions timezone/src/modules/Timezone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
# Authors: Klaus Kaempf <kkaempf@suse.de>
# Thomas Roelz <tom@suse.de>

require "storage"
require "y2storage"

require "yast"
require "y2storage"

module Yast
class TimezoneClass < Module
Expand Down Expand Up @@ -986,23 +984,12 @@ def Summary
HTML.List(ret)
end


# Checks whether the system has Windows installed on a primary partition with NTFS
# Checks whether the system has Windows installed
def system_has_windows?
storage = Y2Storage::StorageManager.instance
Storage::Ntfs::all(storage.probed).each do |ntfs|
ntfs.blk_devices.each do |blk_device|
if Storage::partition?(blk_device)
if Storage::to_partition(blk_device).type == Storage::PartitionType_PRIMARY
return true if ntfs.detect_content_info.windows?
end
end
end
end
false
win_partitions = disk_analyzer.windows_partitions.values.flatten
!win_partitions.empty?
end


publish :variable => :timezone, :type => "string"
publish :variable => :hwclock, :type => "string"
publish :variable => :default_timezone, :type => "string"
Expand Down Expand Up @@ -1045,6 +1032,15 @@ def system_has_windows?
publish :function => :Import, :type => "boolean (map)"
publish :function => :Export, :type => "map ()"
publish :function => :Summary, :type => "string ()"

protected

def disk_analyzer
@disk_analyzer ||= begin
devicegraph = Y2Storage::StorageManager.instance.probed
Y2Storage::DiskAnalyzer.new(devicegraph)
end
end
end

Timezone = TimezoneClass.new
Expand Down

0 comments on commit a16a5cd

Please sign in to comment.