diff options
Diffstat (limited to 'scripts/lib/wic/filemap.py')
-rw-r--r-- | scripts/lib/wic/filemap.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py index 8fe302ab49..8719f443c5 100644 --- a/scripts/lib/wic/filemap.py +++ b/scripts/lib/wic/filemap.py | |||
@@ -530,9 +530,18 @@ def filemap(image, log=None): | |||
530 | except ErrorNotSupp: | 530 | except ErrorNotSupp: |
531 | return FilemapSeek(image, log) | 531 | return FilemapSeek(image, log) |
532 | 532 | ||
533 | def sparse_copy(src_fname, dst_fname, offset=0, skip=0, | 533 | def sparse_copy(src_fname, dst_fname, skip=0, seek=0, |
534 | length=0, api=None): | 534 | length=0, api=None): |
535 | """Efficiently copy sparse file to or into another file.""" | 535 | """ |
536 | Efficiently copy sparse file to or into another file. | ||
537 | |||
538 | src_fname: path to source file | ||
539 | dst_fname: path to destination file | ||
540 | skip: skip N bytes at thestart of src | ||
541 | seek: seek N bytes from the start of dst | ||
542 | length: read N bytes from src and write them to dst | ||
543 | api: FilemapFiemap or FilemapSeek object | ||
544 | """ | ||
536 | if not api: | 545 | if not api: |
537 | api = filemap | 546 | api = filemap |
538 | fmap = api(src_fname) | 547 | fmap = api(src_fname) |
@@ -554,7 +563,7 @@ def sparse_copy(src_fname, dst_fname, offset=0, skip=0, | |||
554 | start = skip | 563 | start = skip |
555 | 564 | ||
556 | fmap._f_image.seek(start, os.SEEK_SET) | 565 | fmap._f_image.seek(start, os.SEEK_SET) |
557 | dst_file.seek(offset + start - skip, os.SEEK_SET) | 566 | dst_file.seek(seek + start - skip, os.SEEK_SET) |
558 | 567 | ||
559 | chunk_size = 1024 * 1024 | 568 | chunk_size = 1024 * 1024 |
560 | to_read = end - start | 569 | to_read = end - start |