MCPcopy
hub / github.com/syncthing/syncthing / WriteAt

Method WriteAt

lib/fs/fakefs.go:909–932  ·  view source on GitHub ↗
(p []byte, off int64)

Source from the content-addressed store, hash-verified

907}
908
909func (f *fakeFile) WriteAt(p []byte, off int64) (int, error) {
910 f.mut.Lock()
911 defer f.mut.Unlock()
912
913 if f.entryType == fakeEntryTypeDir {
914 return 0, errors.New("is a directory")
915 }
916
917 if f.content != nil {
918 if len(f.content) < int(off)+len(p) {
919 newc := make([]byte, int(off)+len(p))
920 copy(newc, f.content)
921 f.content = newc
922 }
923 copy(f.content[int(off):], p)
924 }
925
926 f.rng = nil
927 f.offset = off + int64(len(p))
928 if f.offset > f.size {
929 f.size = f.offset
930 }
931 return len(p), nil
932}
933
934func (f *fakeFile) Name() string {
935 if f.presentedName != "" {

Callers 4

WriteMethod · 0.95
copyRangeStandardFunction · 0.45
TestReadWriteContentFunction · 0.45
decryptFileMethod · 0.45

Calls 2

UnlockMethod · 0.80
NewMethod · 0.65

Tested by 1

TestReadWriteContentFunction · 0.36