def self.mounts
buffer = 0.chr * MAXPATH
length = GetLogicalDriveStrings(buffer.size, buffer)
if length == 0
raise Error, get_last_error
end
mounts = block_given? ? nil : []
if length > buffer.size
buffer = 0.chr * length
if GetLogicalDriveStrings(buffer.size, buffer) == 0
raise Error, get_last_error
end
end
boot_time = get_boot_time
drives = buffer.strip.split("\0")
drives.each{ |drive|
mount = Mount.new
volume = 0.chr * MAXPATH
fsname = 0.chr * MAXPATH
mount.instance_variable_set(:@mount_point, drive)
mount.instance_variable_set(:@mount_time, boot_time)
volume_serial_number = [0].pack('L')
max_component_length = [0].pack('L')
filesystem_flags = [0].pack('L')
bool = GetVolumeInformation(
drive,
volume,
volume.size,
volume_serial_number,
max_component_length,
filesystem_flags,
fsname,
fsname.size
)
unless bool
errnum = GetLastError()
if errnum == ERROR_NOT_READY
next
else
raise Error, get_last_error(errnum)
end
end
filesystem_flags = filesystem_flags.unpack('L')[0]
name = 0.chr * MAXPATH
if QueryDosDevice(drive[0,2], name, name.size) == 0
raise Error, get_last_error
end
mount.instance_variable_set(:@name, name.strip)
mount.instance_variable_set(:@mount_type, fsname.strip)
mount.instance_variable_set(:@options, get_options(filesystem_flags))
if block_given?
yield mount
else
mounts << mount
end
}
mounts
end