Debian Codegraph @

fat/file.go

raw symbols SCIP
1 package fat
2
3 type File struct {
4 chain *ClusterChain
5 dir *Directory
6 entry *DirectoryClusterEntry
7 }
8
9 func (f *File) Read(p []byte) (n int, err error) {
10 return f.chain.Read(p)
11 }
12
13 func (f *File) Write(p []byte) (n int, err error) {
14 lastByte := f.chain.writeOffset + uint32(len(p))
15 if lastByte > f.entry.fileSize {
16 // Increase the file size since we're writing past the end of the file
17 f.entry.fileSize = lastByte
18
19 // Write the entry out
20 if err := f.dir.dirCluster.WriteToDevice(f.dir.device, f.dir.fat); err != nil {
21 return 0, err
22 }
23 }
24
25 return f.chain.Write(p)
26 }