DnDDir.cpp revision 82391de567696f10b21a762fde6a06fe3c266d28
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * DnD: Directory handling.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Copyright (C) 2014 Oracle Corporation
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * available from http://www.virtualbox.org. This file is free software;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * you can redistribute it and/or modify it under the terms of the GNU
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * General Public License (GPL) as published by the Free Software
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/******************************************************************************
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Header Files *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync ******************************************************************************/
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync if (RTStrPrintf(pszDropDir, cbDropDir, "%s", pszPath) <= 0)
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /** @todo On Windows we also could use the registry to override
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * this path, on Posix a dotfile and/or a guest property
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * can be used. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /* Append our base drop directory. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int rc = RTPathAppend(pszDropDir, cbDropDir, "VirtualBox Dropped Files");
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /* Create it when necessary. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync rc = RTDirCreateFullPath(pszDropDir, RTFS_UNIX_IRWXU);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /* The actually drop directory consist of the current time stamp and a
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * unique number when necessary. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync if (!RTTimeSpecToString(RTTimeNow(&time), pszTime, sizeof(pszTime)))
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync rc = DnDPathSanitizeFilename(pszTime, sizeof(pszTime));
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /* Create it (only accessible by the current user) */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync return RTDirCreateUniqueNumbered(pszDropDir, cbDropDir, RTFS_UNIX_IRWXU, 3, '-');
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsyncint DnDDirCreateDroppedFiles(char *pszDropDir, size_t cbDropDir)
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync /* Get the user's temp directory. Don't use the user's root directory (or
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * something inside it) because we don't know for how long/if the data will
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * be kept after the guest OS used it. */