VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/path/RTPathParentLength.cpp.h@ 93115

Last change on this file since 93115 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: 1.8 KB
Line 
1/* $Id: RTPathParentLength.cpp.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * IPRT - RTPathParentLength - Code Template.
4 *
5 * This file included multiple times with different path style macros.
6 */
7
8/*
9 * Copyright (C) 2019-2022 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#include "rtpath-root-length-template.cpp.h"
30
31/**
32 * @copydoc RTPathParentLengthEx
33 */
34static size_t RTPATH_STYLE_FN(rtPathParentLength)(const char *pszPath, uint32_t fFlags)
35{
36 /*
37 * Determin the length of the root component so we can make sure
38 * we don't try ascend higher than it.
39 */
40 size_t const cchRoot = RTPATH_STYLE_FN(rtPathRootLengthEx)(pszPath, fFlags);
41
42 /*
43 * Rewind to the start of the final component.
44 */
45 size_t cch = strlen(pszPath);
46
47 /* Trailing slashes: */
48 while (cch > cchRoot && RTPATH_IS_SLASH(pszPath[cch - 1]))
49 cch--;
50
51 /* The component: */
52 while (cch > cchRoot && !RTPATH_IS_SEP(pszPath[cch - 1]))
53 cch--;
54
55 /* Done! */
56 return cch;
57}
58
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