VirtualBox

source: vbox/trunk/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp

Last change on this file was 106061, checked in by vboxsync, 8 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: ClipboardPath.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Path handling.
4 */
5
6/*
7 * Copyright (C) 2019-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
33#include <VBox/GuestHost/SharedClipboard-transfers.h>
34
35#include <iprt/err.h>
36#include <iprt/path.h>
37#include <iprt/string.h>
38
39
40/**
41 * Sanitizes the file name component so that unsupported characters
42 * will be replaced by an underscore ("_").
43 *
44 * @return IPRT status code.
45 * @param pszPath Path to sanitize.
46 * @param cbPath Size (in bytes) of path to sanitize.
47 */
48int ShClPathSanitizeFilename(char *pszPath, size_t cbPath)
49{
50 int rc = VINF_SUCCESS;
51#ifdef RT_OS_WINDOWS
52 RT_NOREF1(cbPath);
53 /* Replace out characters not allowed on Windows platforms, put in by RTTimeSpecToString(). */
54 /** @todo Use something like RTPathSanitize() if available later some time. */
55 static const RTUNICP s_uszValidRangePairs[] =
56 {
57 ' ', ' ',
58 '(', ')',
59 '-', '.',
60 '0', '9',
61 'A', 'Z',
62 'a', 'z',
63 '_', '_',
64 0xa0, 0xd7af,
65 '\0'
66 };
67 ssize_t cReplaced = RTStrPurgeComplementSet(pszPath, s_uszValidRangePairs, '_' /* chReplacement */);
68 if (cReplaced < 0)
69 rc = VERR_INVALID_UTF8_ENCODING;
70#else
71 RT_NOREF2(pszPath, cbPath);
72#endif
73 return rc;
74}
75
76/**
77 * Sanitizes a given path regarding invalid / unhandled characters.
78 * Currently not implemented.
79 *
80 * @returns VBox status code.
81 * @param pszPath Path to sanitize. UTF-8.
82 * @param cbPath Size (in bytes) of the path to sanitize.
83 */
84int ShClPathSanitize(char *pszPath, size_t cbPath)
85{
86 RT_NOREF(pszPath, cbPath);
87
88 /** @todo */
89
90 return VINF_SUCCESS;
91}
92
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