Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
c2c00b12
Commit
c2c00b12
authored
Apr 16, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Apr 16, 2019
Browse files
ENH: add backslashes handling, UNC descriptors in fileName (
#1008
,
#1238
)
parent
f0a68bfa
Changes
3
Show whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOobject/IOobject.C
View file @
c2c00b12
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
...
...
@@ -152,12 +152,18 @@ bool Foam::IOobject::fileNameComponents
name
=
word
::
validate
(
path
);
}
else
if
(
first
==
0
)
else
if
(
first
==
0
#ifdef _WIN32
||
(
first
==
2
&&
path
[
1
]
==
':'
)
// Eg, d:/path
#endif
)
{
// Absolute path (starts with '/')
// => no local
instance
=
path
.
substr
(
0
,
last
);
instance
=
path
.
substr
(
first
,
last
);
const
std
::
string
ending
=
path
.
substr
(
last
+
1
);
nameLen
=
ending
.
size
();
// The raw length of name
...
...
src/OpenFOAM/primitives/strings/fileName/fileName.C
View file @
c2c00b12
...
...
@@ -60,8 +60,20 @@ Foam::fileName Foam::fileName::validate
std
::
string
::
size_type
len
=
0
;
auto
iter
=
s
.
cbegin
();
#ifdef _WIN32
// Preserve UNC \\server-name\...
if
(
s
.
length
()
>
2
&&
s
[
0
]
==
'\\'
&&
s
[
1
]
==
'\\'
)
{
len
+=
2
;
++
iter
;
++
iter
;
}
#endif
char
prev
=
0
;
for
(
auto
iter
=
s
.
cbegin
()
;
iter
!=
s
.
cend
();
++
iter
)
for
(
/*nil*/
;
iter
!=
s
.
cend
();
++
iter
)
{
char
c
=
*
iter
;
...
...
@@ -74,6 +86,9 @@ Foam::fileName Foam::fileName::validate
c
=
'/'
;
}
// Could explicitly allow space character or rely on
// allowSpaceInFileName via fileName::valid()
if
(
fileName
::
valid
(
c
))
{
if
(
doClean
&&
prev
==
'/'
&&
c
==
'/'
)
...
...
src/OpenFOAM/primitives/strings/fileName/fileNameI.H
View file @
c2c00b12
...
...
@@ -136,7 +136,18 @@ inline bool Foam::fileName::isAbsolute(const std::string& str)
{
return
(
!
str
.
empty
()
&&
str
[
0
]
==
'/'
(
!
str
.
empty
()
&&
str
[
0
]
==
'/'
)
#ifdef _WIN32
||
(
// Eg, d:/path or \\machine/path
(
str
.
length
()
>
2
)
&&
(
(
str
[
1
]
==
':'
&&
str
[
2
]
==
'/'
)
||
(
str
[
0
]
==
'\\'
&&
str
[
1
]
==
'\\'
)
)
)
#endif
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment