File: type.go

package info (click to toggle)
golang-github-mitchellh-go-fs 0.0~git20180402.b7b9ca4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package fat

import "github.com/mitchellh/go-fs"

// FATType is a simple enum of the available FAT filesystem types.
type FATType uint8

const (
	FAT12 FATType = iota
	FAT16
	FAT32
)

// TypeForDevice determines the usable FAT type based solely on
// size information about the block device.
func TypeForDevice(device fs.BlockDevice) FATType {
	sizeInMB := device.Len() / (1024 * 1024)
	switch {
	case sizeInMB < 4:
		return FAT12
	case sizeInMB < 512:
		return FAT16
	default:
		return FAT32
	}
}