VirtualBox

source: vbox/trunk/src/VBox/Runtime/nt/RTNtPathFindPossible8dot3Name.cpp@ 85561

Last change on this file since 85561 was 82968, checked in by vboxsync, 5 years 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.6 KB
Line 
1/* $Id: RTNtPathFindPossible8dot3Name.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * IPRT - Native NT, RTNtPathFindPossible8dot3Name.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define LOG_GROUP RTLOGGROUP_FS
32#ifdef IN_SUP_HARDENED_R3
33# include <iprt/nt/nt-and-windows.h>
34#else
35# include <iprt/nt/nt.h>
36#endif
37
38
39
40/**
41 * Checks whether the path could be containing alternative 8.3 names generated
42 * by NTFS, FAT, or other similar file systems.
43 *
44 * @returns Pointer to the first component that might be an 8.3 name, NULL if
45 * not 8.3 path.
46 * @param pwszPath The path to check.
47 *
48 * @remarks This is making bad ASSUMPTION wrt to the naming scheme of 8.3 names,
49 * however, non-tilde 8.3 aliases are probably rare enough to not be
50 * worth all the extra code necessary to open each path component and
51 * check if we've got the short name or not.
52 */
53RTDECL(PRTUTF16) RTNtPathFindPossible8dot3Name(PCRTUTF16 pwszPath)
54{
55 PCRTUTF16 pwszName = pwszPath;
56 for (;;)
57 {
58 RTUTF16 wc = *pwszPath++;
59 if (wc == '~')
60 {
61 /* Could check more here before jumping to conclusions... */
62 if (pwszPath - pwszName <= 8+1+3)
63 return (PRTUTF16)pwszName;
64 }
65 else if (wc == '\\' || wc == '/' || wc == ':')
66 pwszName = pwszPath;
67 else if (wc == 0)
68 break;
69 }
70 return NULL;
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