Update go-fs.

Closes #6083
This commit is contained in:
Matthew Hooker 2018-04-02 20:13:07 -07:00
parent bc5cf25d69
commit 5206427a47
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
8 changed files with 33 additions and 24 deletions

View File

@ -4,8 +4,9 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/mitchellh/go-fs"
"unicode"
"github.com/mitchellh/go-fs"
)
type MediaType uint8
@ -99,7 +100,7 @@ func (b *BootSectorCommon) Bytes() ([]byte, error) {
for i, r := range b.OEMName {
if r > unicode.MaxASCII {
return nil, fmt.Errorf("'%s' in OEM name not a valid ASCII char. Must be ASCII.", r)
return nil, fmt.Errorf("%#U in OEM name not a valid ASCII char. Must be ASCII.", r)
}
sector[0x3+i] = byte(r)
@ -245,7 +246,7 @@ func (b *BootSectorFat16) Bytes() ([]byte, error) {
for i, r := range b.VolumeLabel {
if r > unicode.MaxASCII {
return nil, fmt.Errorf("'%s' in VolumeLabel not a valid ASCII char. Must be ASCII.", r)
return nil, fmt.Errorf("%#U in VolumeLabel not a valid ASCII char. Must be ASCII.", r)
}
sector[43+i] = byte(r)
@ -258,7 +259,7 @@ func (b *BootSectorFat16) Bytes() ([]byte, error) {
for i, r := range b.FileSystemTypeLabel {
if r > unicode.MaxASCII {
return nil, fmt.Errorf("'%s' in FileSystemTypeLabel not a valid ASCII char. Must be ASCII.", r)
return nil, fmt.Errorf("%#U in FileSystemTypeLabel not a valid ASCII char. Must be ASCII.", r)
}
sector[54+i] = byte(r)
@ -324,7 +325,7 @@ func (b *BootSectorFat32) Bytes() ([]byte, error) {
for i, r := range b.VolumeLabel {
if r > unicode.MaxASCII {
return nil, fmt.Errorf("'%s' in VolumeLabel not a valid ASCII char. Must be ASCII.", r)
return nil, fmt.Errorf("%#U in VolumeLabel not a valid ASCII char. Must be ASCII.", r)
}
sector[71+i] = byte(r)
@ -337,7 +338,7 @@ func (b *BootSectorFat32) Bytes() ([]byte, error) {
for i, r := range b.FileSystemTypeLabel {
if r > unicode.MaxASCII {
return nil, fmt.Errorf("'%s' in FileSystemTypeLabel not a valid ASCII char. Must be ASCII.", r)
return nil, fmt.Errorf("%#U in FileSystemTypeLabel not a valid ASCII char. Must be ASCII.", r)
}
sector[82+i] = byte(r)

View File

@ -1,9 +1,10 @@
package fat
import (
"github.com/mitchellh/go-fs"
"io"
"math"
"github.com/mitchellh/go-fs"
)
type ClusterChain struct {

View File

@ -2,9 +2,10 @@ package fat
import (
"fmt"
"github.com/mitchellh/go-fs"
"strings"
"time"
"github.com/mitchellh/go-fs"
)
// Directory implements fs.Directory and is used to interface with
@ -16,9 +17,9 @@ type Directory struct {
}
// DirectoryEntry implements fs.DirectoryEntry and represents a single
// file/folder within a directory in a FAT filesystem. Note that the
// underlying directory entry data structures on the disk may be more
// than one to accomodate for long filenames.
// file/folder within a directory in a FAT filesystem. Note that there may be
// more than one underlying directory entry data structure on the disk to
// account for long filenames.
type DirectoryEntry struct {
dir *Directory
lfnEntries []*DirectoryClusterEntry

View File

@ -5,11 +5,12 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/mitchellh/go-fs"
"math"
"strings"
"time"
"unicode/utf16"
"github.com/mitchellh/go-fs"
)
type DirectoryAttr uint8
@ -126,7 +127,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
// Create the "." and ".." entries
cluster.entries = []*DirectoryClusterEntry{
&DirectoryClusterEntry{
{
accessTime: t,
attr: AttrDirectory,
cluster: start,
@ -134,7 +135,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
name: ".",
writeTime: t,
},
&DirectoryClusterEntry{
{
accessTime: t,
attr: AttrDirectory,
cluster: parent,

View File

@ -3,8 +3,9 @@ package fat
import (
"errors"
"fmt"
"github.com/mitchellh/go-fs"
"math"
"github.com/mitchellh/go-fs"
)
// The first cluster that can really hold user data is always 2

View File

@ -30,11 +30,11 @@ func generateShortName(longName string, used []string) (string, error) {
if dotIdx == -1 {
dotIdx = len(longName)
} else {
ext = longName[dotIdx+1 : len(longName)]
ext = longName[dotIdx+1:]
}
ext = cleanShortString(ext)
ext = ext[0:len(ext)]
ext = ext[0:]
rawName := longName[0:dotIdx]
name := cleanShortString(rawName)
simpleName := fmt.Sprintf("%s.%s", name, ext)
@ -42,7 +42,7 @@ func generateShortName(longName string, used []string) (string, error) {
simpleName = simpleName[0 : len(simpleName)-1]
}
doSuffix := name != rawName || len(name) > 8
doSuffix := name != rawName || len(name) > 8 || len(ext) > 3
if !doSuffix {
for _, usedSingle := range used {
if strings.ToUpper(usedSingle) == simpleName {
@ -53,6 +53,9 @@ func generateShortName(longName string, used []string) (string, error) {
}
if doSuffix {
if len(ext) > 3 {
ext = ext[:3]
}
found := false
for i := 1; i < 99999; i++ {
serial := fmt.Sprintf("~%d", i)

View File

@ -3,8 +3,9 @@ package fat
import (
"errors"
"fmt"
"github.com/mitchellh/go-fs"
"time"
"github.com/mitchellh/go-fs"
)
// SuperFloppyConfig is the configuration for various properties of

10
vendor/vendor.json vendored
View File

@ -1022,14 +1022,14 @@
{
"checksumSHA1": "mVqDwKcibat0IKAdzAhfGIHPwI8=",
"path": "github.com/mitchellh/go-fs",
"revision": "7bae45d9a684750e82b97ff320c82556614e621b",
"revisionTime": "2016-11-08T19:11:23Z"
"revision": "7b48fa161ea73ce54566b233d6fba8750b2faf47",
"revisionTime": "2018-04-02T23:40:41Z"
},
{
"checksumSHA1": "B5dy+Lg6jFPgHYhozztz88z3b4A=",
"checksumSHA1": "i+3acspzTbQODW3dWX2JKydHVAo=",
"path": "github.com/mitchellh/go-fs/fat",
"revision": "7bae45d9a684750e82b97ff320c82556614e621b",
"revisionTime": "2016-11-08T19:11:23Z"
"revision": "7b48fa161ea73ce54566b233d6fba8750b2faf47",
"revisionTime": "2018-04-02T23:40:41Z"
},
{
"checksumSHA1": "z235fRXw4+SW4xWgLTYc8SwkM2M=",