VirtualBox

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

Last change on this file since 95140 was 93115, checked in by vboxsync, 3 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.5 KB
Line 
1/* $Id: ClipboardPath.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Path handling.
4 */
5
6/*
7 * Copyright (C) 2019-2022 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_SHARED_CLIPBOARD
23#include <VBox/GuestHost/SharedClipboard-transfers.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 ShClPathSanitizeFilename(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
66/**
67 * Sanitizes a given path regarding invalid / unhandled characters.
68 * Currently not implemented.
69 *
70 * @returns VBox status code.
71 * @param pszPath Path to sanitize. UTF-8.
72 * @param cbPath Size (in bytes) of the path to sanitize.
73 */
74int ShClPathSanitize(char *pszPath, size_t cbPath)
75{
76 RT_NOREF(pszPath, cbPath);
77
78 /** @todo */
79
80 return VINF_SUCCESS;
81}
82
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