GuestDirectoryImpl.cpp revision 8bc8d66f188d5357155b8340e2d489573be2b607
/* $Id$ */
/** @file
* VirtualBox Main - XXX.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "GuestDirectoryImpl.h"
#include "GuestSessionImpl.h"
#include "GuestCtrlImplPrivate.h"
#include "Global.h"
#include "AutoCaller.h"
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
LogFlowThisFunc(("\n"));
return BaseFinalConstruct();
}
void GuestDirectory::FinalRelease(void)
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
{
LogFlowThisFunc(("strPath=%s, strFilter=%s, uFlags=%x\n",
/* Enclose the state transition NotReady->InInit->Ready. */
AutoInitSpan autoInitSpan(this);
/* Start the directory process on the guest. */
/* We want the long output format which contains all the object details. */
#if 0 /* Flags are not supported yet. */
#endif
/** @todo Recursion support? */
/*
* Start the process asynchronously and keep it around so that we can use
* it later in subsequent read() calls.
*/
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* Confirm a successful initialization when it's the case. */
return rc;
}
return rc;
}
/**
* Uninitializes the instance.
* Called from FinalRelease().
*/
void GuestDirectory::uninit(void)
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady. */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
}
/////////////////////////////////////////////////////////////////////////////
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
// private methods
/////////////////////////////////////////////////////////////////////////////
{
int rc;
do
{
/* Try parsing the data to see if the current block is complete. */
if (streamBlock.GetCount())
break;
} while (RT_SUCCESS(rc));
return rc;
}
// implementation of public methods
/////////////////////////////////////////////////////////////////////////////
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
uninit();
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
int rc;
/** @todo Make use of exceptions! */
try
{
if ( RT_FAILURE(rc)
{
if (RT_FAILURE(rc))
return setError(VBOX_E_IPRT_ERROR,
tr("Could not start reading directory \"%s\": %Rrc"),
/** @todo Merge with GuestSession::queryFileInfoInternal. */
for (;;)
{
if ( RT_FAILURE(rc)
{
break;
}
&cbRead);
if (RT_FAILURE(rc))
break;
if (cbRead)
{
if (RT_FAILURE(rc))
break;
LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64, cbStreamOut=%RU32\n",
if (RT_SUCCESS(rc))
{
/* Parsing the current stream block succeeded so
* we don't need more at the moment. */
break;
}
}
}
LogFlowThisFunc(("Reading done with rc=%Rrc, cbRead=%RU64, cbStream=%RU32\n",
if (RT_SUCCESS(rc))
{
rc = VINF_SUCCESS;
}
/*
* Note: The guest process can still be around to serve the next
* upcoming stream block next time.
*/
if (RT_SUCCESS(rc))
{
/** @todo Move into common function. */
if ( ( procStatus != ProcessStatus_Started
)
&& exitCode != 0)
{
return setError(VBOX_E_IPRT_ERROR,
tr("Reading directory \"%s\" failed: Unable to read / access denied"),
}
}
}
if (RT_SUCCESS(rc))
{
{
if (RT_FAILURE(rc))
return setError(VBOX_E_IPRT_ERROR,
tr("Reading directory \"%s\" failed: Path not found"),
/* Create the object. */
/* Return info object to the caller. */
}
else
{
/* Nothing to read anymore. Tell the caller. */
}
}
}
catch (int rc2)
{
}
return hr;
#endif /* VBOX_WITH_GUEST_CONTROL */
}