Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockDevice ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir represents an open FAT directory.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
Example (Basic_usage) ¶
package main import ( "fmt" "io" "github.com/soypat/fat" ) func main() { // device could be an SD card, RAM, or anything that implements the BlockDevice interface. device := fat.DefaultFATByteBlocks(32000) var fs fat.FS err := fs.Mount(device, device.BlockSize(), fat.ModeRW) if err != nil { panic(err) } var file fat.File err = fs.OpenFile(&file, "newfile.txt", fat.ModeCreateAlways|fat.ModeWrite) if err != nil { panic(err) } _, err = file.Write([]byte("Hello, World!")) if err != nil { panic(err) } err = file.Close() if err != nil { panic(err) } // Read back the file: err = fs.OpenFile(&file, "newfile.txt", fat.ModeRead) if err != nil { panic(err) } data, err := io.ReadAll(&file) if err != nil { panic(err) } fmt.Println(string(data)) file.Close() }
Output: Hello, World!
func (*FS) Mount ¶
func (fsys *FS) Mount(bd BlockDevice, blockSize int, mode Mode) error
Mount mounts the FAT file system on the given block device and sector size. It immediately invalidates previously open files and directories pointing to the same FS. Mode should be ModeRead, ModeWrite, or both.
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) Read ¶
Read reads up to len(buf) bytes from the File. It implements the io.Reader interface.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
func (*FileInfo) AlternateName ¶
AlternateName returns the alternate name of the file.
type FormatConfig ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
func (*Formatter) Format ¶
func (f *Formatter) Format(bd BlockDevice, blocksize, fsSizeInBlocks int, cfg FormatConfig) error
type Mode ¶
type Mode uint8
Mode represents the file access mode used in Open.
const ( ModeRead Mode = Mode(faRead) ModeWrite Mode = Mode(faWrite) ModeRW Mode = ModeRead | ModeWrite ModeCreateNew Mode = Mode(faCreateNew) ModeCreateAlways Mode = Mode(faCreateAlways) ModeOpenExisting Mode = Mode(faOpenExisting) ModeOpenAppend Mode = Mode(faOpenAppend) )
File access modes for calling Open.
Click to show internal directories.
Click to hide internal directories.