VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/path/rtpath-root-length-template.cpp.h@ 91538

Last change on this file since 91538 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.5 KB
Line 
1/* $Id: rtpath-root-length-template.cpp.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * IPRT - rtPathRootLengthEx - Code Template.
4 *
5 * Include this from a path-style template file.
6 */
7
8/*
9 * Copyright (C) 2019-2020 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * The contents of this file may alternatively be used under the terms
20 * of the Common Development and Distribution License Version 1.0
21 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
22 * VirtualBox OSE distribution, in which case the provisions of the
23 * CDDL are applicable instead of those of the GPL.
24 *
25 * You may elect to license modified versions of this file under the
26 * terms and conditions of either the GPL or the CDDL or both.
27 */
28
29
30/*********************************************************************************************************************************
31* Header Files *
32*********************************************************************************************************************************/
33#include <iprt/ctype.h>
34
35
36/**
37 * Inlined helper for determining the length of the root component.
38 */
39DECLINLINE(size_t) RTPATH_STYLE_FN(rtPathRootLengthEx)(const char *pszPath, uint32_t fFlags)
40{
41 if (RTPATH_IS_SLASH(pszPath[0]))
42 {
43 if (fFlags & RTPATH_STR_F_NO_START)
44 return 0;
45#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
46 if (RTPATH_IS_SLASH(pszPath[1]))
47 {
48 /* UNC - there are exactly two prefix slashes followed by a namespace
49 or computer name, which can be empty on windows. */
50 size_t cchRoot = 2;
51 while (!RTPATH_IS_SLASH(pszPath[cchRoot]) && pszPath[cchRoot])
52 cchRoot++;
53 if (RTPATH_IS_SLASH(pszPath[cchRoot]))
54 cchRoot++;
55 return cchRoot;
56 }
57#endif
58 return 1;
59 }
60#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
61 if (RT_C_IS_ALPHA(pszPath[0]) && pszPath[1] == ':')
62 {
63 if (!RTPATH_IS_SLASH(pszPath[2]))
64 return 2;
65 return 3;
66 }
67#endif
68 return 0;
69}
70
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