SharedFolderImpl.cpp revision 2c75187df4bc65eae9117019c2190800bd1a7aa1
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#include "SharedFolderImpl.h"
#include "VirtualBoxImpl.h"
#include "MachineImpl.h"
#include "ConsoleImpl.h"
#include "Logging.h"
#include <iprt/cpputils.h>
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return S_OK;
}
void SharedFolder::FinalRelease()
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the shared folder object.
*
* @param aMachine parent Machine object
* @param aName logical name of the shared folder
* @param aHostPath full path to the shared folder on the host
*
* @return COM result indicator
*/
{
}
/**
* Initializes the shared folder object given another object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*
* @param aMachine parent Machine object
* @param aThat shared folder object to copy
*
* @return COM result indicator
*/
{
}
/**
* Initializes the shared folder object.
*
* @param aConsole Console parent object
* @param aName logical name of the shared folder
* @param aHostPath full path to the shared folder on the host
*
* @return COM result indicator
*/
{
}
/**
* Initializes the shared folder object.
*
* @param aVirtualBox VirtualBox parent object
* @param aName logical name of the shared folder
* @param aHostPath full path to the shared folder on the host
*
* @return COM result indicator
*/
{
}
/**
* Helper for init() methods.
*
* @note
* Must be called from under the object's lock!
*/
{
/* Remove the trailng slash unless it's a root directory
* (otherwise the comparison with the RTPathAbs() result will fail at least
* on Linux). Note that this isn't really necessary for the shared folder
* itself, since adding a mapping eventually results into a
* RTDirOpenFiltered() call (see HostServices/SharedFolders) that seems to
* accept both the slashified paths and not. */
if (hostPathLen > 2 &&
;
#else
;
#endif
else
/* Check whether the path is full (absolute) */
char hostPathFull [RTPATH_MAX];
hostPathFull, sizeof (hostPathFull));
if (VBOX_FAILURE (vrc))
return setError (E_INVALIDARG,
return setError (E_INVALIDARG,
mParent->addDependentChild (this);
setReady (true);
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void SharedFolder::uninit()
{
LogFlowMember (("SharedFolder::uninit()\n"));
if (!isReady())
return;
setReady (false);
mParent->removeDependentChild (this);
}
// ISharedFolder properties
/////////////////////////////////////////////////////////////////////////////
{
if (!aName)
return E_POINTER;
CHECK_READY();
return S_OK;
}
{
if (!aHostPath)
return E_POINTER;
CHECK_READY();
return S_OK;
}
{
if (!aAccessible)
return E_POINTER;
CHECK_READY();
// check whether the host path exists
char hostPathFull [RTPATH_MAX];
if (VBOX_SUCCESS (vrc))
{
*aAccessible = TRUE;
return S_OK;
}
if (vrc != VERR_PATH_NOT_FOUND)
Log (("SharedFolder::COMGETTER(Accessible): WARNING: '%s' "
*aAccessible = FALSE;
return S_OK;
}