82391de567696f10b21a762fde6a06fe3c266d28vboxsync/* $Id$ */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync/** @file
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * DnD: Path handling.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync
82391de567696f10b21a762fde6a06fe3c266d28vboxsync/*
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Copyright (C) 2014 Oracle Corporation
82391de567696f10b21a762fde6a06fe3c266d28vboxsync *
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
82391de567696f10b21a762fde6a06fe3c266d28vboxsync/******************************************************************************
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Header Files *
82391de567696f10b21a762fde6a06fe3c266d28vboxsync ******************************************************************************/
82391de567696f10b21a762fde6a06fe3c266d28vboxsync
82391de567696f10b21a762fde6a06fe3c266d28vboxsync#include <iprt/path.h>
82391de567696f10b21a762fde6a06fe3c266d28vboxsync#include <iprt/string.h>
82391de567696f10b21a762fde6a06fe3c266d28vboxsync
82391de567696f10b21a762fde6a06fe3c266d28vboxsync#include <VBox/GuestHost/DragAndDrop.h>
82391de567696f10b21a762fde6a06fe3c266d28vboxsync
82391de567696f10b21a762fde6a06fe3c266d28vboxsync/**
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * Sanitizes the file name component so that unsupported characters
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * will be replaced by an underscore ("_").
82391de567696f10b21a762fde6a06fe3c266d28vboxsync *
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * @return IPRT status code.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * @param pszPath Path to sanitize.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync * @param cbPath Size (in bytes) of path to sanitize.
82391de567696f10b21a762fde6a06fe3c266d28vboxsync */
82391de567696f10b21a762fde6a06fe3c266d28vboxsyncint DnDPathSanitizeFilename(char *pszPath, size_t cbPath)
82391de567696f10b21a762fde6a06fe3c266d28vboxsync{
82391de567696f10b21a762fde6a06fe3c266d28vboxsync int rc = VINF_SUCCESS;
82391de567696f10b21a762fde6a06fe3c266d28vboxsync#ifdef RT_OS_WINDOWS
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /* Filter out characters not allowed on Windows platforms, put in by
82391de567696f10b21a762fde6a06fe3c266d28vboxsync RTTimeSpecToString(). */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /** @todo Use something like RTPathSanitize() when available. Later. */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync RTUNICP aCpSet[] =
82391de567696f10b21a762fde6a06fe3c266d28vboxsync { ' ', ' ', '(', ')', '-', '.', '0', '9', 'A', 'Z', 'a', 'z', '_', '_',
82391de567696f10b21a762fde6a06fe3c266d28vboxsync 0xa0, 0xd7af, '\0' };
82391de567696f10b21a762fde6a06fe3c266d28vboxsync ssize_t cReplaced = RTStrPurgeComplementSet(pszPath, aCpSet, '_' /* Replacement */);
82391de567696f10b21a762fde6a06fe3c266d28vboxsync if (cReplaced < 0)
82391de567696f10b21a762fde6a06fe3c266d28vboxsync rc = VERR_INVALID_UTF8_ENCODING;
82391de567696f10b21a762fde6a06fe3c266d28vboxsync#endif
82391de567696f10b21a762fde6a06fe3c266d28vboxsync return rc;
82391de567696f10b21a762fde6a06fe3c266d28vboxsync}
82391de567696f10b21a762fde6a06fe3c266d28vboxsync
82391de567696f10b21a762fde6a06fe3c266d28vboxsyncint DnDPathSanitize(char *pszPath, size_t cbPath)
82391de567696f10b21a762fde6a06fe3c266d28vboxsync{
82391de567696f10b21a762fde6a06fe3c266d28vboxsync /** @todo */
82391de567696f10b21a762fde6a06fe3c266d28vboxsync return VINF_SUCCESS;
82391de567696f10b21a762fde6a06fe3c266d28vboxsync}
82391de567696f10b21a762fde6a06fe3c266d28vboxsync