VirtualBox

Changeset 77797 in vbox


Ignore:
Timestamp:
Mar 19, 2019 5:14:25 PM (6 years ago)
Author:
vboxsync
Message:

IPRT: Adding RTFileCopyRange and RTFileCopyRangEx for optimizing file copying on linux and windows (shared folders). bugref:9172

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/file.h

    r77681 r77797  
    675675RTDECL(int) RTFileCopyByHandlesEx(RTFILE FileSrc, RTFILE FileDst, PFNRTPROGRESS pfnProgress, void *pvUser);
    676676
     677/**
     678 * Copies a part of a file to another one.
     679 *
     680 * @returns IPRT status code.
     681 * @retval  VERR_EOF if @a pcbCopied is NULL and the end-of-file is reached
     682 *          before @a cbToCopy bytes have been copied.
     683 *
     684 * @param   hFileSrc    Handle to the source file.  Must be readable.
     685 * @param   offSrc      The source file offset.
     686 * @param   hFileDst    Handle to the destination file.  Must be writable and
     687 *                      RTFILE_O_APPEND must be be in effect.
     688 * @param   offDst      The destination file offset.
     689 * @param   cbToCopy    How many bytes to copy.
     690 * @param   fFlags      Reserved for the future, must be zero.
     691 * @param   pcbCopied   Where to return the exact number of bytes copied.
     692 *                      Optional.
     693 *
     694 * @note    The file positions of @a hFileSrc and @a hFileDst are undefined
     695 *          upon return of this function.
     696 *
     697 * @sa      RTFileCopyPartEx.
     698 */
     699RTDECL(int) RTFileCopyPart(RTFILE hFileSrc, RTFOFF offSrc, RTFILE hFileDst, RTFOFF offDst, uint64_t cbToCopy,
     700                           uint32_t fFlags, uint64_t *pcbCopied);
     701
     702
     703/** Copy buffer state for RTFileCopyPartEx.
     704 * @note The fields are considered internal!
     705 */
     706typedef struct RTFILECOPYPARTBUFSTATE
     707{
     708    /** Magic value (RTFILECOPYPARTBUFSTATE_MAGIC).
     709     * @internal */
     710    uint32_t    uMagic;
     711    /** Allocation type (internal).
     712     * @internal */
     713    int32_t     iAllocType;
     714    /** Buffer pointer.
     715     * @internal */
     716    uint8_t    *pbBuf;
     717    /** Buffer size.
     718     * @internal */
     719    size_t      cbBuf;
     720    /** Reserved.
     721     * @internal */
     722    void       *papReserved[3];
     723} RTFILECOPYPARTBUFSTATE;
     724/** Pointer to copy buffer state for RTFileCopyPartEx(). */
     725typedef RTFILECOPYPARTBUFSTATE *PRTFILECOPYPARTBUFSTATE;
     726/** Magic value for the RTFileCopyPartEx() buffer state structure (Stephen John Fry). */
     727#define RTFILECOPYPARTBUFSTATE_MAGIC   UINT32_C(0x19570857)
     728
     729/**
     730 * Prepares buffer state for one or more RTFileCopyPartEx() calls.
     731 *
     732 * Caller must call RTFileCopyPartCleanup() after the final RTFileCopyPartEx()
     733 * call.
     734 *
     735 * @returns IPRT status code.
     736 * @param   pBufState   The buffer state to prepare.
     737 * @param   cbToCopy    The number of bytes we typically to copy in one
     738 *                      RTFileCopyPartEx call.
     739 */
     740RTDECL(int) RTFileCopyPartPrep(PRTFILECOPYPARTBUFSTATE pBufState, uint64_t cbToCopy);
     741
     742/**
     743 * Cleans up after RTFileCopyPartPrep() once the final RTFileCopyPartEx()
     744 * call has been made.
     745 *
     746 * @param   pBufState   The buffer state to clean up.
     747 */
     748RTDECL(void) RTFileCopyPartCleanup(PRTFILECOPYPARTBUFSTATE pBufState);
     749
     750/**
     751 * Copies a part of a file to another one, extended version.
     752 *
     753 * @returns IPRT status code.
     754 * @retval  VERR_EOF if @a pcbCopied is NULL and the end-of-file is reached
     755 *          before @a cbToCopy bytes have been copied.
     756 *
     757 * @param   hFileSrc    Handle to the source file.  Must be readable.
     758 * @param   offSrc      The source file offset.
     759 * @param   hFileDst    Handle to the destination file.  Must be writable and
     760 *                      RTFILE_O_APPEND must be be in effect.
     761 * @param   offDst      The destination file offset.
     762 * @param   cbToCopy    How many bytes to copy.
     763 * @param   fFlags      Reserved for the future, must be zero.
     764 * @param   pBufState   Copy buffer state prepared by RTFileCopyPartPrep().
     765 * @param   pcbCopied   Where to return the exact number of bytes copied.
     766 *                      Optional.
     767 *
     768 * @note    The file positions of @a hFileSrc and @a hFileDst are undefined
     769 *          upon return of this function.
     770 *
     771 * @sa      RTFileCopyPartEx.
     772 */
     773RTDECL(int) RTFileCopyPartEx(RTFILE hFileSrc, RTFOFF offSrc, RTFILE hFileDst, RTFOFF offDst, uint64_t cbToCopy,
     774                             uint32_t fFlags, PRTFILECOPYPARTBUFSTATE pBufState, uint64_t *pcbCopied);
    677775
    678776/**
  • trunk/include/iprt/mangling.h

    r77758 r77797  
    918918# define RTFileCopyByHandlesEx                          RT_MANGLER(RTFileCopyByHandlesEx)
    919919# define RTFileCopyEx                                   RT_MANGLER(RTFileCopyEx)
     920# define RTFileCopyPart                                 RT_MANGLER(RTFileCopyPart)
     921# define RTFileCopyPartCleanup                          RT_MANGLER(RTFileCopyPartCleanup)
     922# define RTFileCopyPartEx                               RT_MANGLER(RTFileCopyPartEx)
     923# define RTFileCopyPartPrep                             RT_MANGLER(RTFileCopyPartPrep)
    920924# define RTFileCreateTemp                               RT_MANGLER(RTFileCreateTemp)
    921925# define RTFileCreateTempSecure                         RT_MANGLER(RTFileCreateTempSecure)
  • trunk/src/VBox/Runtime/Makefile.kmk

    r77632 r77797  
    666666        generic/RTEnvDupEx-generic.cpp \
    667667        generic/RTFileCopy-generic.cpp \
     668        generic/RTFileCopyRange-generic.cpp \
     669        generic/RTFileCopyRangeEx-generic.cpp \
    668670        generic/RTFileQuerySize-generic.cpp \
    669671        generic/RTFileReadAll-generic.cpp \
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette