VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/path/rtPathVolumeSpecLen.cpp@ 21675

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

IPRT: Moved rtPathVolumeSpecLen.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* $Id: rtPathVolumeSpecLen.cpp 21675 2009-07-17 12:18:30Z vboxsync $ */
2/** @file
3 * IPRT - rtPathVolumeSpecLen
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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/string.h>
37#include "internal/path.h"
38
39
40
41/**
42 * Returns the length of the volume name specifier of the given path.
43 * If no such specifier zero is returned.
44 */
45size_t rtPathVolumeSpecLen(const char *pszPath)
46{
47#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
48 if (pszPath && *pszPath)
49 {
50 /* UTC path. */
51 /** @todo r=bird: it's UNC and we have to check that the next char isn't a
52 * slash, then skip both the server and the share name. */
53 if ( (pszPath[0] == '\\' || pszPath[0] == '/')
54 && (pszPath[1] == '\\' || pszPath[1] == '/'))
55 return strcspn(pszPath + 2, "\\/") + 2;
56
57 /* Drive letter. */
58 if ( pszPath[1] == ':'
59 && toupper(pszPath[0]) >= 'A' && toupper(pszPath[0]) <= 'Z')
60 return 2;
61 }
62 return 0;
63
64#else
65 /* This isn't quite right when looking at the above stuff, but it works assuming that '//' does not mean UNC. */
66 /// @todo (dmik) well, it's better to consider there's no volume name
67 // at all on *nix systems
68 return 0;
69// return pszPath && pszPath[0] == '/';
70#endif
71}
72
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