VirtualBox

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


Ignore:
Timestamp:
Feb 10, 2009 6:53:32 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42635
Message:

IPRT: implement RTFileSetMode on Windows.

File:
1 edited

Legend:

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

    r14064 r16650  
    209209            return VERR_INVALID_PARAMETER;
    210210    }
     211    /* RTFileSetMode needs following rights as well. */
     212    dwDesiredAccess |= FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE;
    211213
    212214    DWORD dwShareMode;
     
    724726
    725727
     728/* This comes from a source file with a different set of system headers (DDK)
     729 * so it can't be declared in a common header, like internal/file.h.
     730 */
     731extern int rtFileNativeSetAttributes(HANDLE FileHandle, ULONG FileAttributes);
     732
     733
    726734RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode)
    727735{
    728     /** @todo darn. this needs a full path; probably must be done if the file is closed
    729      * It's quite possible that there is an NT API for this. NtSetInformationFile() for instance. */
     736    /*
     737     * Normalize the mode and call the API.
     738     */
     739    fMode = rtFsModeNormalize(fMode, NULL, 0);
     740    if (!rtFsModeIsValid(fMode))
     741        return VERR_INVALID_PARAMETER;
     742
     743    ULONG FileAttributes = (fMode & RTFS_DOS_MASK) >> RTFS_DOS_SHIFT;
     744    int Err = rtFileNativeSetAttributes((HANDLE)File, FileAttributes);
     745    if (Err != ERROR_SUCCESS)
     746    {
     747        int rc = RTErrConvertFromWin32(Err);
     748        Log(("RTFileSetMode(%RTfile, %RTfmode): rtFileNativeSetAttributes (0x%08X) failed with err %d (%Rrc)\n",
     749             File, fMode, FileAttributes, Err, rc));
     750        return rc;
     751    }
    730752    return VINF_SUCCESS;
    731753}
Note: See TracChangeset for help on using the changeset viewer.

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