filesystem_copy_range_allwithfallback.go 769 B

12345678910111213141516171819202122
  1. // Copyright (C) 2019 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package fs
  7. func init() {
  8. registerCopyRangeImplementation(CopyRangeMethodAllWithFallback, copyRangeAllWithFallback)
  9. }
  10. func copyRangeAllWithFallback(src, dst File, srcOffset, dstOffset, size int64) error {
  11. var err error
  12. for _, method := range []CopyRangeMethod{CopyRangeMethodIoctl, CopyRangeMethodCopyFileRange, CopyRangeMethodSendFile, CopyRangeMethodDuplicateExtents, CopyRangeMethodStandard} {
  13. if err = CopyRange(method, src, dst, srcOffset, dstOffset, size); err == nil {
  14. return nil
  15. }
  16. }
  17. return err
  18. }