Documentation ¶
Overview ¶
Package gofat is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ParseDate(input uint16) time.Time
- func ParseTime(input uint16) time.Time
- type BPB
- type EntryHeader
- type ExtendedEntryHeader
- type FAT16SpecificData
- type FAT32SpecificData
- type FATType
- type File
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) Read(p []byte) (n int, err error)
- func (f *File) ReadAt(p []byte, off int64) (n int, err error)
- func (f *File) Readdir(count int) ([]os.FileInfo, error)
- func (f *File) Readdirnames(count int) ([]string, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(p []byte) (n int, err error)
- func (f *File) WriteAt(p []byte, off int64) (n int, err error)
- func (f *File) WriteString(s string) (ret int, err error)
- type Fs
- func (f *Fs) Chmod(name string, mode os.FileMode) error
- func (f *Fs) Chown(name string, uid, gid int) error
- func (f *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (f *Fs) Create(name string) (afero.File, error)
- func (f *Fs) FSType() FATType
- func (f *Fs) Label() string
- func (f *Fs) Mkdir(name string, perm os.FileMode) error
- func (f *Fs) MkdirAll(path string, perm os.FileMode) error
- func (f *Fs) Name() string
- func (f *Fs) Open(path string) (afero.File, error)
- func (f *Fs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (f *Fs) Remove(name string) error
- func (f *Fs) RemoveAll(path string) error
- func (f *Fs) Rename(oldname, newname string) error
- func (f *Fs) Stat(path string) (os.FileInfo, error)
- type GoDirEntry
- type GoFile
- type GoFs
- type Info
- type LongFilenameEntry
- type MockfatFileFs
- type MockfatFileFsMockRecorder
- type Sector
Constants ¶
const ( AttrReadOnly = 0x01 AttrHidden = 0x02 AttrSystem = 0x04 AttrVolumeId = 0x08 AttrDirectory = 0x10 AttrArchive = 0x20 AttrDevice = 0x40 AttrReserved = 0x80 AttrLongName = AttrReadOnly | AttrHidden | AttrSystem | AttrVolumeId )
Variables ¶
var ( ErrReadFile = errors.New("could not read file completely") ErrSeekFile = errors.New("could not seek inside of the file") ErrReadDir = errors.New("could not read the directory") )
These errors may occur while processing a file.
var ( ErrInvalidPath = errors.New("invalid path") ErrOpenFilesystem = errors.New("could not open the filesystem") ErrReadFilesystemFile = errors.New("could not read file completely from the filesystem") ErrReadFilesystemDir = errors.New("could not a directory from the filesystem") ErrNotSupported = errors.New("not supported") ErrInitializeFilesystem = errors.New("initialize the filesystem") ErrFetchingSector = errors.New("could not fetch a new sector") ErrReadFat = errors.New("could not read FAT sector") )
These errors may occur while processing a FAT filesystem.
Functions ¶
func ParseDate ¶ added in v0.2.0
ParseDate reads the given input as a date like it is specified in the specification:
A FAT directory entry date stamp is a 16- bit field that is basically a date relative to the MS- DOS epoch of 01/01 / 19 80. Here is the format (bit 0 is the LSB of the 16- bit word, bit 15 is the MSB of the 16- bit word): Bits 0–4: Day of month, valid value range 1- 31 inclusive. Bits 5–8: Month of year, 1 = January, valid value range 1–12 inclusive. Bits 9–15: Count of years from 1980, valid value range 0–127 inclusive (1980–2107).
It returns a time.Time which has always a time of 00:00:00.000000000 UTC.
As value 0 for day and month is defined as invalid in the specification the value time.Time{} is used to be compatible with time.Time.IsZero() if any of that cases occurs.
Note that monthOfYear may be bigger than 12 which is unspecified. In this case the year gets incremented by one.
func ParseTime ¶ added in v0.2.0
ParseTime reads the given input as a date like it is specified in the specification:
A FAT directory entry time stamp is a 16- bit field that has a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the 16- bit word, bit 15 is the MSB of the 16- bit word). Bits 0–4: 2- second count, valid value range 0–29 inclusive (0 – 58 seconds). Bits 5–10: Minutes, valid value range 0–59 inclusive. Bits 11–15: Hours, valid value range 0–23 inclusive. The valid time range is from Midnight 00:00:00 to 23:59:58.
It returns a time.Time which has always a date of of January 1, year 1. That way in case of seconds == 0, minutes == 0 and hours == 0 time.Time.IsZero() can be used.
Note that bigger values than the specified ones are just added to the time. But this is limited to 23:59:59. This edge case should happen rarely and only if the time filed is invalid.
Types ¶
type BPB ¶
type BPB struct { BSJumpBoot [3]byte BSOEMName [8]byte BytesPerSector uint16 SectorsPerCluster byte ReservedSectorCount uint16 NumFATs byte RootEntryCount uint16 TotalSectors16 uint16 Media byte FATSize16 uint16 SectorsPerTrack uint16 NumberOfHeads uint16 HiddenSectors uint32 TotalSectors32 uint32 FATSpecificData [54]byte }
type EntryHeader ¶
type ExtendedEntryHeader ¶
type ExtendedEntryHeader struct { EntryHeader ExtendedName string }
func (*ExtendedEntryHeader) FileInfo ¶
func (h *ExtendedEntryHeader) FileInfo() os.FileInfo
type FAT16SpecificData ¶
type FAT32SpecificData ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) Readdir ¶
Readdir reads the contents of a directory. May return syscall.ENOTDIR if the current File is no directory.
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
func New ¶
func New(reader io.ReadSeeker) (*Fs, error)
New opens a FAT filesystem from the given reader.
func NewSkipChecks ¶
func NewSkipChecks(reader io.ReadSeeker) (*Fs, error)
NewSkipChecks opens a FAT filesystem from the given reader just like New but it skips some filesystem validations which may allow you to open not perfectly standard FAT filesystems. Use with caution!
type GoDirEntry ¶ added in v0.4.0
func (GoDirEntry) Type ¶ added in v0.4.0
func (g GoDirEntry) Type() fs.FileMode
type GoFs ¶ added in v0.4.0
type GoFs struct {
Fs
}
GoFs just wraps the afero FAT implementation to be compatible with fs.FS.
func NewGoFS ¶ added in v0.4.0
func NewGoFS(reader io.ReadSeeker) (*GoFs, error)
NewGoFS opens a FAT filesystem from the given reader as fs.FS compatible filesystem.
func NewGoFSSkipChecks ¶ added in v0.4.0
func NewGoFSSkipChecks(reader io.ReadSeeker) (*GoFs, error)
NewGoFSSkipChecks opens a FAT filesystem from the given reader as fs.FS compatible filesystem just like NewGoFs but it skips some filesystem validations which may allow you to open not perfectly standard FAT filesystems. Use with caution!
type Info ¶
type Info struct { FSType FATType FatCount uint8 FatSize uint32 SectorsPerCluster uint8 FirstDataSector uint32 TotalSectorCount uint32 ReservedSectorCount uint16 BytesPerSector uint16 Label string RootEntryCount uint16 // RootEntryCount is only needed for < FAT32. // contains filtered or unexported fields }
Info contains all information about the whole filesystem.
type LongFilenameEntry ¶
type MockfatFileFs ¶ added in v0.3.0
type MockfatFileFs struct {
// contains filtered or unexported fields
}
MockfatFileFs is a mock of fatFileFs interface.
func NewMockfatFileFs ¶ added in v0.3.0
func NewMockfatFileFs(ctrl *gomock.Controller) *MockfatFileFs
NewMockfatFileFs creates a new mock instance.
func (*MockfatFileFs) EXPECT ¶ added in v0.3.0
func (m *MockfatFileFs) EXPECT() *MockfatFileFsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockfatFileFsMockRecorder ¶ added in v0.3.0
type MockfatFileFsMockRecorder struct {
// contains filtered or unexported fields
}
MockfatFileFsMockRecorder is the mock recorder for MockfatFileFs.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package checkpoint provides a way to decorate errors by some additional caller information which results in something similar to a stacktrace.
|
Package checkpoint provides a way to decorate errors by some additional caller information which results in something similar to a stacktrace. |
cmd
|
|