blob: 37d05249a49ee039d1c18cd92335a1ee46452eb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceUtil/FileUtil.h>
using namespace std;
//
// Detemine if path is an absolute path
//
bool
IceUtilInternal::isAbsolutePath(const string& path)
{
size_t i = 0;
size_t size = path.size();
// Skip whitespace
while(i < size && isspace(static_cast<unsigned char>(path[i])))
{
++i;
}
#ifdef _WIN32
// We need at least 3 non whitespace character to have
// and absolute path
if(i + 3 > size)
{
return false;
}
// Check for X:\ path ('\' may have been converted to '/')
if((path[i] >= 'A' && path[i] <= 'Z') || (path[i] >= 'a' && path[i] <= 'z'))
{
return path[i + 1] == ':' && (path[i + 2] == '\\' || path[i + 2] == '/');
}
// Check for UNC path
return (path[i] == '\\' && path[i + 1] == '\\') || path[i] == '/';
#else
if(i >= size)
{
return false;
}
return path[i] == '/';
#endif
}
|