DnDURIList.cpp revision 82391de567696f10b21a762fde6a06fe3c266d28
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * DnD: URI list class.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Copyright (C) 2014 Oracle Corporation
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * available from http://www.virtualbox.org. This file is free software;
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * you can redistribute it and/or modify it under the terms of the GNU
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * General Public License (GPL) as published by the Free Software
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync/******************************************************************************
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Header Files *
82391de567696f10b21a762fde6a06fe3c266d28vboxsync ******************************************************************************/
82391de567696f10b21a762fde6a06fe3c266d28vboxsyncint DnDURIList::appendPathRecursive(const char *pcszPath, size_t cbBaseLen,
82391de567696f10b21a762fde6a06fe3c266d28vboxsync int rc = RTPathQueryInfo(pcszPath, &objInfo, RTFSOBJATTRADD_NOTHING);
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * These are the types we currently support. Symlinks are not directly
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * supported. First the guest could be an OS which doesn't support it and
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * second the symlink could point to a file which is out of the base tree.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Both things are hard to support. For now we just copy the target file in
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * this case.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync m_lstTree.append(DnDURIPath(pcszPath, &pcszPath[cbBaseLen],
82391de567696f10b21a762fde6a06fe3c266d28vboxsync LogFlowFunc(("strHostPath=%s, strGuestPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n",
82391de567696f10b21a762fde6a06fe3c266d28vboxsync pcszPath, &pcszPath[cbBaseLen], objInfo.Attr.fMode, cbSize, m_cbTotal));
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* We have to try to open even symlinks, cause they could
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * be symlinks to directories. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* The following error happens when this was a symlink
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * to an file or a regular file. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* Skip "." and ".." entries. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync char *pszRecDir = RTStrAPrintf2("%s%c%s", pcszPath,
82391de567696f10b21a762fde6a06fe3c266d28vboxsync rc = appendPathRecursive(pszRecDir, cbBaseLen, fFlags);
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* We need the size and the mode of the file. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync rc = RTPathQueryInfo(pszNewFile, &objInfo1, RTFSOBJATTRADD_NOTHING);
82391de567696f10b21a762fde6a06fe3c266d28vboxsync m_lstTree.append(DnDURIPath(pszNewFile, &pszNewFile[cbBaseLen],
82391de567696f10b21a762fde6a06fe3c266d28vboxsync LogFlowFunc(("strHostPath=%s, strGuestPath=%s, fMode=0x%x, cbSize=%RU64, cbTotal=%zu\n",
82391de567696f10b21a762fde6a06fe3c266d28vboxsync pszNewFile, &pszNewFile[cbBaseLen], objInfo1.Attr.fMode, cbSize, m_cbTotal));
82391de567696f10b21a762fde6a06fe3c266d28vboxsyncint DnDURIList::AppendPath(const char *pszPath, uint32_t fFlags)
82391de567696f10b21a762fde6a06fe3c266d28vboxsync LogFlowFunc(("pszPath=%s, fFlags=0x%x\n", pszPath, fFlags));
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* Query the path component of a file URI. If this hasn't a
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * file scheme NULL is returned. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync char *pszFilePath = RTUriFilePath(pszPath, URI_FILE_FORMAT_AUTO);
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* Add the path to our internal file list (recursive in
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * the case of a directory). */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync else /* Just append the raw data. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsyncint DnDURIList::AppendPathsFromList(const RTCList<RTCString> &lstURI,
82391de567696f10b21a762fde6a06fe3c266d28vboxsync m_cbTotal -= curPath.m_cbSize; /* Adjust total size. */