MCPcopy
hub / github.com/rclone/rclone / _writeAt

Method _writeAt

vfs/read_write.go:329–362  ·  view source on GitHub ↗

_writeAt bytes to the file at off if release is set then it releases the mutex just before doing the IO call with lock held

(b []byte, off int64, release bool)

Source from the content-addressed store, hash-verified

327//
328// call with lock held
329func (fh *RWFileHandle) _writeAt(b []byte, off int64, release bool) (n int, err error) {
330 defer log.Trace(fh.logPrefix(), "size=%d, off=%d", len(b), off)("n=%d, err=%v", &n, &err)
331 if fh.closed {
332 return n, ECLOSED
333 }
334 if fh.readOnly() {
335 return n, EBADF
336 }
337 if err = fh.openPending(); err != nil {
338 return n, err
339 }
340 if fh.flags&os.O_APPEND != 0 {
341 // From open(2): Before each write(2), the file offset is
342 // positioned at the end of the file, as if with lseek(2).
343 size := fh._size()
344 fh.offset = size
345 off = fh.offset
346 }
347 fh.writeCalled = true
348 if release {
349 // Do the writing with fh.mu unlocked
350 fh.mu.Unlock()
351 }
352 n, err = fh.item.WriteAt(b, off)
353 if release {
354 fh.mu.Lock()
355 }
356 if err != nil {
357 return n, err
358 }
359
360 _ = fh._size()
361 return n, err
362}
363
364// WriteAt bytes to the file at off
365func (fh *RWFileHandle) WriteAt(b []byte, off int64) (n int, err error) {

Callers 2

WriteAtMethod · 0.95
WriteMethod · 0.95

Calls 8

logPrefixMethod · 0.95
readOnlyMethod · 0.95
openPendingMethod · 0.95
_sizeMethod · 0.95
TraceFunction · 0.92
UnlockMethod · 0.65
WriteAtMethod · 0.65
LockMethod · 0.65

Tested by

no test coverage detected