VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/path/RTPathTraverseList.cpp@ 67849

Last change on this file since 67849 was 62477, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/* $Id: RTPathTraverseList.cpp 62477 2016-07-22 18:27:37Z vboxsync $ */
2/** @file
3 * IPRT - RTPathTraverseList
4 */
5
6/*
7 * Copyright (C) 2009-2016 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#include "internal/iprt.h"
32#include <iprt/path.h>
33
34#include <iprt/assert.h>
35#include <iprt/ctype.h>
36#include <iprt/err.h>
37#include <iprt/string.h>
38
39
40RTDECL(int) RTPathTraverseList(const char *pszPathList, char chSep, PFNRTPATHTRAVERSER pfnCallback, void *pvUser1, void *pvUser2)
41{
42 AssertPtrNull(pszPathList);
43 Assert((unsigned int)chSep <= 127);
44
45 if (!pszPathList)
46 return VERR_END_OF_STRING;
47
48 /*
49 * Walk the path list.
50 */
51 const char *psz = pszPathList;
52 while (*psz)
53 {
54 /* Skip leading blanks - no directories with leading spaces, thank you. */
55 while (RT_C_IS_BLANK(*psz))
56 psz++;
57
58 /* Find the end of this element. */
59 const char *pszNext;
60 const char *pszEnd = strchr(psz, chSep);
61 if (!pszEnd)
62 pszEnd = pszNext = strchr(psz, '\0');
63 else
64 pszNext = pszEnd + 1;
65 if (pszEnd != psz)
66 {
67 size_t const cch = pszEnd - psz;
68 int rc = pfnCallback(psz, cch, pvUser1, pvUser2);
69 if (rc != VERR_TRY_AGAIN)
70 return rc;
71 }
72
73 /* advance */
74 psz = pszNext;
75 }
76
77 return VERR_END_OF_STRING;
78}
79RT_EXPORT_SYMBOL(RTPathTraverseList);
80
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