parent
bc5cf25d69
commit
5206427a47
|
@ -4,8 +4,9 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MediaType uint8
|
type MediaType uint8
|
||||||
|
@ -99,7 +100,7 @@ func (b *BootSectorCommon) Bytes() ([]byte, error) {
|
||||||
|
|
||||||
for i, r := range b.OEMName {
|
for i, r := range b.OEMName {
|
||||||
if r > unicode.MaxASCII {
|
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)
|
sector[0x3+i] = byte(r)
|
||||||
|
@ -245,7 +246,7 @@ func (b *BootSectorFat16) Bytes() ([]byte, error) {
|
||||||
|
|
||||||
for i, r := range b.VolumeLabel {
|
for i, r := range b.VolumeLabel {
|
||||||
if r > unicode.MaxASCII {
|
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)
|
sector[43+i] = byte(r)
|
||||||
|
@ -258,7 +259,7 @@ func (b *BootSectorFat16) Bytes() ([]byte, error) {
|
||||||
|
|
||||||
for i, r := range b.FileSystemTypeLabel {
|
for i, r := range b.FileSystemTypeLabel {
|
||||||
if r > unicode.MaxASCII {
|
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)
|
sector[54+i] = byte(r)
|
||||||
|
@ -324,7 +325,7 @@ func (b *BootSectorFat32) Bytes() ([]byte, error) {
|
||||||
|
|
||||||
for i, r := range b.VolumeLabel {
|
for i, r := range b.VolumeLabel {
|
||||||
if r > unicode.MaxASCII {
|
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)
|
sector[71+i] = byte(r)
|
||||||
|
@ -337,7 +338,7 @@ func (b *BootSectorFat32) Bytes() ([]byte, error) {
|
||||||
|
|
||||||
for i, r := range b.FileSystemTypeLabel {
|
for i, r := range b.FileSystemTypeLabel {
|
||||||
if r > unicode.MaxASCII {
|
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)
|
sector[82+i] = byte(r)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package fat
|
package fat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClusterChain struct {
|
type ClusterChain struct {
|
||||||
|
|
|
@ -2,9 +2,10 @@ package fat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Directory implements fs.Directory and is used to interface with
|
// 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
|
// DirectoryEntry implements fs.DirectoryEntry and represents a single
|
||||||
// file/folder within a directory in a FAT filesystem. Note that the
|
// file/folder within a directory in a FAT filesystem. Note that there may be
|
||||||
// underlying directory entry data structures on the disk may be more
|
// more than one underlying directory entry data structure on the disk to
|
||||||
// than one to accomodate for long filenames.
|
// account for long filenames.
|
||||||
type DirectoryEntry struct {
|
type DirectoryEntry struct {
|
||||||
dir *Directory
|
dir *Directory
|
||||||
lfnEntries []*DirectoryClusterEntry
|
lfnEntries []*DirectoryClusterEntry
|
||||||
|
|
|
@ -5,11 +5,12 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DirectoryAttr uint8
|
type DirectoryAttr uint8
|
||||||
|
@ -126,7 +127,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
|
||||||
|
|
||||||
// Create the "." and ".." entries
|
// Create the "." and ".." entries
|
||||||
cluster.entries = []*DirectoryClusterEntry{
|
cluster.entries = []*DirectoryClusterEntry{
|
||||||
&DirectoryClusterEntry{
|
{
|
||||||
accessTime: t,
|
accessTime: t,
|
||||||
attr: AttrDirectory,
|
attr: AttrDirectory,
|
||||||
cluster: start,
|
cluster: start,
|
||||||
|
@ -134,7 +135,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
|
||||||
name: ".",
|
name: ".",
|
||||||
writeTime: t,
|
writeTime: t,
|
||||||
},
|
},
|
||||||
&DirectoryClusterEntry{
|
{
|
||||||
accessTime: t,
|
accessTime: t,
|
||||||
attr: AttrDirectory,
|
attr: AttrDirectory,
|
||||||
cluster: parent,
|
cluster: parent,
|
||||||
|
|
|
@ -3,8 +3,9 @@ package fat
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The first cluster that can really hold user data is always 2
|
// The first cluster that can really hold user data is always 2
|
||||||
|
|
|
@ -30,11 +30,11 @@ func generateShortName(longName string, used []string) (string, error) {
|
||||||
if dotIdx == -1 {
|
if dotIdx == -1 {
|
||||||
dotIdx = len(longName)
|
dotIdx = len(longName)
|
||||||
} else {
|
} else {
|
||||||
ext = longName[dotIdx+1 : len(longName)]
|
ext = longName[dotIdx+1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
ext = cleanShortString(ext)
|
ext = cleanShortString(ext)
|
||||||
ext = ext[0:len(ext)]
|
ext = ext[0:]
|
||||||
rawName := longName[0:dotIdx]
|
rawName := longName[0:dotIdx]
|
||||||
name := cleanShortString(rawName)
|
name := cleanShortString(rawName)
|
||||||
simpleName := fmt.Sprintf("%s.%s", name, ext)
|
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]
|
simpleName = simpleName[0 : len(simpleName)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
doSuffix := name != rawName || len(name) > 8
|
doSuffix := name != rawName || len(name) > 8 || len(ext) > 3
|
||||||
if !doSuffix {
|
if !doSuffix {
|
||||||
for _, usedSingle := range used {
|
for _, usedSingle := range used {
|
||||||
if strings.ToUpper(usedSingle) == simpleName {
|
if strings.ToUpper(usedSingle) == simpleName {
|
||||||
|
@ -53,6 +53,9 @@ func generateShortName(longName string, used []string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if doSuffix {
|
if doSuffix {
|
||||||
|
if len(ext) > 3 {
|
||||||
|
ext = ext[:3]
|
||||||
|
}
|
||||||
found := false
|
found := false
|
||||||
for i := 1; i < 99999; i++ {
|
for i := 1; i < 99999; i++ {
|
||||||
serial := fmt.Sprintf("~%d", i)
|
serial := fmt.Sprintf("~%d", i)
|
||||||
|
|
|
@ -3,8 +3,9 @@ package fat
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/go-fs"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SuperFloppyConfig is the configuration for various properties of
|
// SuperFloppyConfig is the configuration for various properties of
|
||||||
|
|
|
@ -1022,14 +1022,14 @@
|
||||||
{
|
{
|
||||||
"checksumSHA1": "mVqDwKcibat0IKAdzAhfGIHPwI8=",
|
"checksumSHA1": "mVqDwKcibat0IKAdzAhfGIHPwI8=",
|
||||||
"path": "github.com/mitchellh/go-fs",
|
"path": "github.com/mitchellh/go-fs",
|
||||||
"revision": "7bae45d9a684750e82b97ff320c82556614e621b",
|
"revision": "7b48fa161ea73ce54566b233d6fba8750b2faf47",
|
||||||
"revisionTime": "2016-11-08T19:11:23Z"
|
"revisionTime": "2018-04-02T23:40:41Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "B5dy+Lg6jFPgHYhozztz88z3b4A=",
|
"checksumSHA1": "i+3acspzTbQODW3dWX2JKydHVAo=",
|
||||||
"path": "github.com/mitchellh/go-fs/fat",
|
"path": "github.com/mitchellh/go-fs/fat",
|
||||||
"revision": "7bae45d9a684750e82b97ff320c82556614e621b",
|
"revision": "7b48fa161ea73ce54566b233d6fba8750b2faf47",
|
||||||
"revisionTime": "2016-11-08T19:11:23Z"
|
"revisionTime": "2018-04-02T23:40:41Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "z235fRXw4+SW4xWgLTYc8SwkM2M=",
|
"checksumSHA1": "z235fRXw4+SW4xWgLTYc8SwkM2M=",
|
||||||
|
|
Loading…
Reference in New Issue