DnDURIList.cpp revision 8c71acd3714d92a0602a95d19fbb2aef0cf5fd5d
/* $Id$ */
/** @file
* DnD: URI list class.
*/
/*
* Copyright (C) 2014 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 *
******************************************************************************/
#ifdef LOG_GROUP
#endif
#define LOG_GROUP LOG_GROUP_GUEST_DND
const RTCString &strSrcPath,
const RTCString &strDstPath,
, m_cbProcessed(0)
{
RT_ZERO(u);
}
DnDURIObject::~DnDURIObject(void)
{
}
void DnDURIObject::closeInternal(void)
{
{
if (u.m_hFile)
{
RTFileClose(u.m_hFile);
}
}
}
bool DnDURIObject::IsComplete(void) const
{
bool fComplete = false;
if (m_cbProcessed == m_cbSize)
fComplete = true;
switch (m_Type)
{
case File:
if (!fComplete)
break;
case Directory:
fComplete = true;
break;
default:
break;
}
return fComplete;
}
/* static */
/** @todo Put this into an own class like DnDURIPath : public RTCString? */
const RTCString &strBaseOld,
const RTCString &strBaseNew)
{
int rc;
if (pszPath)
{
const char *pszPathStart = pszPath;
if ( pszBaseOld
{
}
rc = VINF_SUCCESS;
if (RT_SUCCESS(rc))
{
if (pszPathNew)
{
pszPathNew /* pszPath */,
if (pszPathURI)
{
#ifdef DEBUG_andy
#endif
rc = VINF_SUCCESS;
}
else
}
else
rc = VERR_NO_MEMORY;
}
}
else
#ifdef DEBUG_andy
#endif
return rc;
}
{
/* pcbRead is optional. */
int rc;
switch (m_Type)
{
case File:
{
if (!u.m_hFile)
{
/* Open files on the source with RTFILE_O_DENY_WRITE to prevent races
* where the OS writes to the file while the destination side transfers
* it over. */
}
else
rc = VINF_SUCCESS;
bool fDone = false;
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (pcbRead)
m_cbProcessed += cbRead;
/* End of file reached or error occurred? */
if ( m_cbProcessed == m_cbSize
|| RT_FAILURE(rc))
{
}
}
}
break;
}
case Directory:
{
rc = VINF_SUCCESS;
break;
}
default:
break;
}
LogFlowFunc(("Returning strSourcePath=%s, rc=%Rrc\n",
return rc;
}
/*** */
DnDURIList::DnDURIList(void)
: m_cbTotal(0)
{
}
DnDURIList::~DnDURIList(void)
{
}
{
if (RT_FAILURE(rc))
return rc;
/*
* These are the types we currently support. Symlinks are not directly
* supported. First the guest could be an OS which doesn't support it and
* second the symlink could point to a file which is out of the base tree.
* Both things are hard to support. For now we just copy the target file in
* this case.
*/
return VINF_SUCCESS;
if (rc == VERR_IS_A_DIRECTORY)
rc = VINF_SUCCESS;
if (RT_FAILURE(rc))
return rc;
: DnDURIObject::File,
#ifdef DEBUG_andy
LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n",
#endif
/* We have to try to open even symlinks, cause they could
* be symlinks to directories. */
/* The following error happens when this was a symlink
* to an file or a regular file. */
if ( rc == VERR_PATH_NOT_FOUND
|| rc == VERR_NOT_A_DIRECTORY)
return VINF_SUCCESS;
if (RT_FAILURE(rc))
return rc;
while (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
{
if (rc == VERR_NO_MORE_FILES)
rc = VINF_SUCCESS;
break;
}
{
case RTDIRENTRYTYPE_DIRECTORY:
{
/* Skip "." and ".." entries. */
break;
if (pszRecDir)
{
}
else
rc = VERR_NO_MEMORY;
break;
}
case RTDIRENTRYTYPE_SYMLINK:
case RTDIRENTRYTYPE_FILE:
{
if (pszNewFile)
{
/* We need the size and the mode of the file. */
if (RT_FAILURE(rc))
return rc;
rc = VINF_SUCCESS;
if (RT_FAILURE(rc))
break;
{
}
else /* Handle symlink directories. */
#ifdef DEBUG_andy
LogFlowFunc(("strSrcPath=%s, strDstPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n",
#endif
}
else
rc = VERR_NO_MEMORY;
break;
}
default:
break;
}
}
return rc;
}
{
int rc;
if (pszPathNative)
{
if (pszPathURI)
{
}
else
}
else
rc = VERR_NO_MEMORY;
return rc;
}
{
}
{
int rc = VINF_SUCCESS;
{
if (RT_FAILURE(rc))
break;
}
return rc;
}
{
/** @todo Check for string termination? */
#ifdef DEBUG_andy
#endif
int rc = VINF_SUCCESS;
/* Query the path component of a file URI. If this hasn't a
* file scheme NULL is returned. */
if (pszFilePath)
{
/* Add the path to our internal file list (recursive in
* the case of a directory). */
if (cbPathLen)
{
if (pszFileName)
{
? 0 /* Use start of path as root. */
: pszFileName - pszFilePath;
#ifdef DEBUG_andy
LogFlowFunc(("pszFilePath=%s, pszFileName=%s, pszRoot=%s\n",
#endif
fFlags);
}
else
rc = VERR_NOT_FOUND;
}
else
}
else
return rc;
}
{
}
{
int rc = VINF_SUCCESS;
{
if (RT_FAILURE(rc))
break;
}
return rc;
}
void DnDURIList::Clear(void)
{
m_cbTotal = 0;
}
void DnDURIList::RemoveFirst(void)
{
}
{
return VINF_SUCCESS;
int rc = VINF_SUCCESS;
{
/* Query the path component of a file URI. If this hasn't a
* file scheme, NULL is returned. */
#ifdef DEBUG_andy
#endif
if (pszFilePath)
{
if (RT_SUCCESS(rc))
}
else
if (RT_FAILURE(rc))
break;
}
return rc;
}
{
{
#ifdef DEBUG_andy
#endif
if (strBasePath.isNotEmpty())
{
if (pszPath)
{
if (pszPathURI)
{
#ifdef DEBUG_andy
#endif
}
else
break;
}
else
break;
}
else
{
if (pszPathURI)
{
#ifdef DEBUG_andy
#endif
}
else
break;
}
}
return strRet;
}