VirtualBox

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

Last change on this file since 27411 was 22311, checked in by vboxsync, 16 years ago

RTPathTraverseList.cpp: gcc warning.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/* $Id: RTPathTraverseList.cpp 22311 2009-08-17 22:15:06Z vboxsync $ */
2/** @file
3 * IPRT - RTPathTraverseList
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "internal/iprt.h"
36#include <iprt/path.h>
37
38#include <iprt/assert.h>
39#include <iprt/ctype.h>
40#include <iprt/err.h>
41#include <iprt/string.h>
42
43
44RTDECL(int) RTPathTraverseList(const char *pszPathList, char chSep, PFNRTPATHTRAVERSER pfnCallback, void *pvUser1, void *pvUser2)
45{
46 AssertPtrNull(pszPathList);
47 Assert((unsigned int)chSep <= 127);
48
49 if (!pszPathList)
50 return VERR_END_OF_STRING;
51
52 /*
53 * Walk the path list.
54 */
55 const char *psz = pszPathList;
56 while (*psz)
57 {
58 /* Skip leading blanks - no directories with leading spaces, thank you. */
59 while (RT_C_IS_BLANK(*psz))
60 psz++;
61
62 /* Find the end of this element. */
63 const char *pszNext;
64 const char *pszEnd = strchr(psz, chSep);
65 if (!pszEnd)
66 pszEnd = pszNext = strchr(psz, '\0');
67 else
68 pszNext = pszEnd + 1;
69 if (pszEnd != psz)
70 {
71 size_t const cch = pszEnd - psz;
72 int rc = pfnCallback(psz, cch, pvUser1, pvUser2);
73 if (rc != VERR_TRY_AGAIN)
74 return rc;
75 }
76
77 /* advance */
78 psz = pszNext;
79 }
80
81 return VERR_END_OF_STRING;
82}
83RT_EXPORT_SYMBOL(RTPathTraverseList);
84
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette