VirtualBox

source: vbox/trunk/src/VBox/GuestHost/DragAndDrop/DnDPath.cpp@ 78406

Last change on this file since 78406 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/* $Id: DnDPath.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * DnD - Path handling.
4 */
5
6/*
7 * Copyright (C) 2014-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_GUEST_DND
23#include <VBox/GuestHost/DragAndDrop.h>
24
25#include <iprt/err.h>
26#include <iprt/path.h>
27#include <iprt/string.h>
28
29
30/**
31 * Sanitizes the file name component so that unsupported characters
32 * will be replaced by an underscore ("_").
33 *
34 * @return IPRT status code.
35 * @param pszPath Path to sanitize.
36 * @param cbPath Size (in bytes) of path to sanitize.
37 */
38int DnDPathSanitizeFilename(char *pszPath, size_t cbPath)
39{
40 int rc = VINF_SUCCESS;
41#ifdef RT_OS_WINDOWS
42 RT_NOREF1(cbPath);
43 /* Replace out characters not allowed on Windows platforms, put in by RTTimeSpecToString(). */
44 /** @todo Use something like RTPathSanitize() if available later some time. */
45 static const RTUNICP s_uszValidRangePairs[] =
46 {
47 ' ', ' ',
48 '(', ')',
49 '-', '.',
50 '0', '9',
51 'A', 'Z',
52 'a', 'z',
53 '_', '_',
54 0xa0, 0xd7af,
55 '\0'
56 };
57 ssize_t cReplaced = RTStrPurgeComplementSet(pszPath, s_uszValidRangePairs, '_' /* chReplacement */);
58 if (cReplaced < 0)
59 rc = VERR_INVALID_UTF8_ENCODING;
60#else
61 RT_NOREF2(pszPath, cbPath);
62#endif
63 return rc;
64}
65
66int DnDPathSanitize(char *pszPath, size_t cbPath)
67{
68 /** @todo */
69 RT_NOREF2(pszPath, cbPath);
70 return VINF_SUCCESS;
71}
72
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette