VirtualBox

Changeset 96124 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Aug 8, 2022 11:14:54 PM (2 years ago)
Author:
vboxsync
Message:

IPRT: Added a RTFileDup API, only implemented on windows for now as I to tired to bother with dynamically checking for dup3 support. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r96076 r96124  
    406406
    407407
     408RTDECL(int)  RTFileDup(RTFILE hFileSrc, uint64_t fFlags, PRTFILE phFileNew)
     409{
     410    /*
     411     * Validate input.
     412     */
     413    AssertPtrReturn(phFileNew, VERR_INVALID_POINTER);
     414    *phFileNew = NIL_RTFILE;
     415    AssertPtrReturn(phFileNew, VERR_INVALID_POINTER);
     416    AssertReturn(!(fFlags & ~(uint64_t)RTFILE_O_INHERIT), VERR_INVALID_FLAGS);
     417
     418    /*
     419     * Do the job.
     420     */
     421    HANDLE hNew = INVALID_HANDLE_VALUE;
     422    if (DuplicateHandle(GetCurrentProcess(), (HANDLE)RTFileToNative(hFileSrc),
     423                        GetCurrentProcess(), &hNew, 0, RT_BOOL(fFlags & RTFILE_O_INHERIT), DUPLICATE_SAME_ACCESS))
     424    {
     425        *phFileNew = (RTFILE)hNew;
     426        return VINF_SUCCESS;
     427    }
     428    return RTErrConvertFromWin32(GetLastError());
     429}
     430
     431
    408432RTR3DECL(int)  RTFileClose(RTFILE hFile)
    409433{
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