mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
This commit is contained in:
committed by
Andrew Heather
parent
f0a68bfa58
commit
c2c00b121e
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -152,12 +152,18 @@ bool Foam::IOobject::fileNameComponents
|
|||||||
|
|
||||||
name = word::validate(path);
|
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 '/')
|
// Absolute path (starts with '/')
|
||||||
// => no local
|
// => no local
|
||||||
|
|
||||||
instance = path.substr(0, last);
|
instance = path.substr(first, last);
|
||||||
|
|
||||||
const std::string ending = path.substr(last+1);
|
const std::string ending = path.substr(last+1);
|
||||||
nameLen = ending.size(); // The raw length of name
|
nameLen = ending.size(); // The raw length of name
|
||||||
|
|||||||
@ -60,8 +60,20 @@ Foam::fileName Foam::fileName::validate
|
|||||||
|
|
||||||
std::string::size_type len = 0;
|
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;
|
char prev = 0;
|
||||||
for (auto iter = s.cbegin(); iter != s.cend(); ++iter)
|
for (/*nil*/; iter != s.cend(); ++iter)
|
||||||
{
|
{
|
||||||
char c = *iter;
|
char c = *iter;
|
||||||
|
|
||||||
@ -74,6 +86,9 @@ Foam::fileName Foam::fileName::validate
|
|||||||
c = '/';
|
c = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Could explicitly allow space character or rely on
|
||||||
|
// allowSpaceInFileName via fileName::valid()
|
||||||
|
|
||||||
if (fileName::valid(c))
|
if (fileName::valid(c))
|
||||||
{
|
{
|
||||||
if (doClean && prev == '/' && c == '/')
|
if (doClean && prev == '/' && c == '/')
|
||||||
|
|||||||
@ -136,7 +136,18 @@ inline bool Foam::fileName::isAbsolute(const std::string& str)
|
|||||||
{
|
{
|
||||||
return
|
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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user