DrvRawFile.cpp revision ad48e47654d22f79b025dc4b21cb162cb123801a
c366016ffe1788c6847d0a967a954713725cab5evboxsync * VBox stream drivers - Raw file output.
c366016ffe1788c6847d0a967a954713725cab5evboxsync * Copyright (C) 2006-2010 Oracle Corporation
c366016ffe1788c6847d0a967a954713725cab5evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c366016ffe1788c6847d0a967a954713725cab5evboxsync * available from http://www.virtualbox.org. This file is free software;
c366016ffe1788c6847d0a967a954713725cab5evboxsync * you can redistribute it and/or modify it under the terms of the GNU
c366016ffe1788c6847d0a967a954713725cab5evboxsync * General Public License (GPL) as published by the Free Software
c366016ffe1788c6847d0a967a954713725cab5evboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c366016ffe1788c6847d0a967a954713725cab5evboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c366016ffe1788c6847d0a967a954713725cab5evboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c366016ffe1788c6847d0a967a954713725cab5evboxsync/*******************************************************************************
c366016ffe1788c6847d0a967a954713725cab5evboxsync* Header Files *
c366016ffe1788c6847d0a967a954713725cab5evboxsync*******************************************************************************/
c366016ffe1788c6847d0a967a954713725cab5evboxsync/*******************************************************************************
c366016ffe1788c6847d0a967a954713725cab5evboxsync* Defined Constants And Macros *
c366016ffe1788c6847d0a967a954713725cab5evboxsync*******************************************************************************/
c366016ffe1788c6847d0a967a954713725cab5evboxsync/** Converts a pointer to DRVRAWFILE::IMedia to a PDRVRAWFILE. */
c366016ffe1788c6847d0a967a954713725cab5evboxsync#define PDMISTREAM_2_DRVRAWFILE(pInterface) ( (PDRVRAWFILE)((uintptr_t)pInterface - RT_OFFSETOF(DRVRAWFILE, IStream)) )
c366016ffe1788c6847d0a967a954713725cab5evboxsync/*******************************************************************************
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync* Structures and Typedefs *
c366016ffe1788c6847d0a967a954713725cab5evboxsync*******************************************************************************/
c366016ffe1788c6847d0a967a954713725cab5evboxsync * Raw file output driver instance data.
c366016ffe1788c6847d0a967a954713725cab5evboxsync * @implements PDMISTREAM
c366016ffe1788c6847d0a967a954713725cab5evboxsynctypedef struct DRVRAWFILE
c366016ffe1788c6847d0a967a954713725cab5evboxsync /** The stream interface. */
c366016ffe1788c6847d0a967a954713725cab5evboxsync /** Pointer to the driver instance. */
c366016ffe1788c6847d0a967a954713725cab5evboxsync /** Pointer to the file name. (Freed by MM) */
c366016ffe1788c6847d0a967a954713725cab5evboxsync /** Flag whether VirtualBox represents the server or client side. */
c366016ffe1788c6847d0a967a954713725cab5evboxsync/* -=-=-=-=- PDMISTREAM -=-=-=-=- */
6dd8f5023a9ba7588212331db90059553136fe33vboxsync/** @copydoc PDMISTREAM::pfnWrite */
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsyncstatic DECLCALLBACK(int) drvRawFileWrite(PPDMISTREAM pInterface, const void *pvBuf, size_t *pcbWrite)
c366016ffe1788c6847d0a967a954713725cab5evboxsync PDRVRAWFILE pThis = PDMISTREAM_2_DRVRAWFILE(pInterface);
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync LogFlow(("%s: pvBuf=%p *pcbWrite=%#x (%s)\n", __FUNCTION__, pvBuf, *pcbWrite, pThis->pszLocation));
c366016ffe1788c6847d0a967a954713725cab5evboxsync rc = RTFileWrite(pThis->hOutputFile, pvBuf, *pcbWrite, &cbWritten);
c366016ffe1788c6847d0a967a954713725cab5evboxsync /* don't flush here, takes too long and we will loose characters */
return rc;
return NULL;
rc = RTFileOpen(&pThis->hOutputFile, pThis->pszLocation, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("RawFile#%d failed to create the raw output file %s"), pDrvIns->iInstance, pThis->pszLocation);
return VINF_SUCCESS;
sizeof(DRVRAWFILE),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,