VirtualBox

Changeset 8925 in vbox for trunk/include/iprt/file.h


Ignore:
Timestamp:
May 19, 2008 4:59:11 PM (17 years ago)
Author:
vboxsync
Message:

New file APIs for reading (or mapping) a file into memory: RTFileReadAll, RTFileReadAllEx, RTFileReadAllByHandle, RTFileReadAllByHandleEx and RTFileReadAllFree.

File:
1 edited

Legend:

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

    r8559 r8925  
    657657RTR3DECL(int) RTFileIoCtl(RTFILE File, int iRequest, void *pvData, unsigned cbData, int *piRet);
    658658
     659/**
     660 * Reads the file into memory.
     661 *
     662 * The caller must free the memory using RTFileReadAllFree().
     663 *
     664 * @returns IPRT status code.
     665 * @param   pszFilename     The name of the file.
     666 * @param   ppvFile         Where to store the pointer to the memory on successful return.
     667 * @param   pcbFile         Where to store the size of the file on successful return.
     668 *
     669 * @remarks Note that this function may be implemented using memory mapping, which means
     670 *          that the file may remain open until RTFileReadAllFree() is called. It also
     671 *          means that the return memory may reflect the state of the file when it's
     672 *          accessed instead of when this call was done. So, in short, don't use this
     673 *          API for volatile files, then rather use the extended variant with a
     674 *          yet-to-be-defined.
     675 */
     676RTDECL(int) RTFileReadAll(const char *pszFilename, void **ppvFile, size_t *pcbFile);
     677
     678/**
     679 * Reads the file into memory.
     680 *
     681 * The caller must free the memory using RTFileReadAllFree().
     682 *
     683 * @returns IPRT status code.
     684 * @param   pszFilename     The name of the file.
     685 * @param   off             The offset to start reading at.
     686 * @param   cbMax           The maximum number of bytes to read into memory. Specify RTFOFF_MAX
     687 *                          to read to the end of the file.
     688 * @param   fFlags          Flags for the future, must be 0.
     689 * @param   ppvFile         Where to store the pointer to the memory on successful return.
     690 * @param   pcbFile         Where to store the size of the file on successful return.
     691 *
     692 * @remarks See the remarks for RTFileReadAll.
     693 */
     694RTDECL(int) RTFileReadAllEx(const char *pszFilename, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
     695
     696/**
     697 * Reads the file into memory.
     698 *
     699 * The caller must free the memory using RTFileReadAllFree().
     700 *
     701 * @returns IPRT status code.
     702 * @param   File            The handle to the file.
     703 * @param   ppvFile         Where to store the pointer to the memory on successful return.
     704 * @param   pcbFile         Where to store the size of the file on successful return.
     705 *
     706 * @remarks See the remarks for RTFileReadAll.
     707 */
     708RTDECL(int) RTFileReadAllByHandle(RTFILE File, void **ppvFile, size_t *pcbFile);
     709
     710/**
     711 * Reads the file into memory.
     712 *
     713 * The caller must free the memory using RTFileReadAllFree().
     714 *
     715 * @returns IPRT status code.
     716 * @param   File            The handle to the file.
     717 * @param   off             The offset to start reading at.
     718 * @param   cbMax           The maximum number of bytes to read into memory. Specify RTFOFF_MAX
     719 *                          to read to the end of the file.
     720 * @param   fFlags          Flags for the future, must be 0.
     721 * @param   ppvFile         Where to store the pointer to the memory on successful return.
     722 * @param   pcbFile         Where to store the size of the file on successful return.
     723 *
     724 * @remarks See the remarks for RTFileReadAll.
     725 */
     726RTDECL(int) RTFileReadAllByHandleEx(RTFILE File, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
     727
     728/**
     729 * Frees the memory returned by one of the RTFileReadAll(), RTFileReadAllEx(),
     730 * RTFileReadAllByHandle() and RTFileReadAllByHandleEx() functions.
     731 *
     732 * @param   pvFile          Pointer to the memory.
     733 * @param   cbFile          The size of the memory.
     734 */
     735RTDECL(int) RTFileReadAllFree(void **ppvFile, size_t *pcbFile);
     736
    659737#endif /* IN_RING3 */
    660738
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